mirror of git://gcc.gnu.org/git/gcc.git
PR inline-asm/52813 revisited
The original patch for this PR made it an error to list the stack pointer in the clobber list of an inline asm. However, the general feeling seemed to be that going straight to a hard error was too harsh, since there's quite a bit of existing code that has the clobber. This patch implements the compromise discussed on IRC of making it a -Wdeprecated warning instead. 2019-01-15 Richard Sandiford <richard.sandiford@arm.com> gcc/ PR inline-asm/52813 * doc/extend.texi: Document that listing the stack pointer in the clobber list of an asm is a deprecated feature. * common.opt (Wdeprecated): Moved from c-family/c.opt. * cfgexpand.c (asm_clobber_reg_is_valid): Issue a -Wdeprecated warning instead of an error for clobbers of the stack pointer. Add a note explaining why. gcc/c-family/ PR inline-asm/52813 * c.opt (Wdeprecated): Move documentation and variable to common.opt. gcc/d/ PR inline-asm/52813 * lang.opt (Wdeprecated): Reference common.opt instead of c.opt. gcc/testsuite/ PR inline-asm/52813 * gcc.target/i386/pr52813.c (test1): Turn the diagnostic into a -Wdeprecated warning and expect a following note:. From-SVN: r267941
This commit is contained in:
parent
17f781605e
commit
99063eeecb
|
|
@ -1,3 +1,13 @@
|
|||
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
PR inline-asm/52813
|
||||
* doc/extend.texi: Document that listing the stack pointer in the
|
||||
clobber list of an asm is a deprecated feature.
|
||||
* common.opt (Wdeprecated): Moved from c-family/c.opt.
|
||||
* cfgexpand.c (asm_clobber_reg_is_valid): Issue a -Wdeprecated
|
||||
warning instead of an error for clobbers of the stack pointer.
|
||||
Add a note explaining why.
|
||||
|
||||
2019-01-15 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR debug/88046
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
PR inline-asm/52813
|
||||
* c.opt (Wdeprecated): Move documentation and variable to common.opt.
|
||||
|
||||
2019-01-14 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* c-cppbuiltin.c (c_cpp_builtin): Define __cpp_guaranteed_copy_elision
|
||||
|
|
|
|||
|
|
@ -477,8 +477,8 @@ C++ ObjC++ Var(warn_delnonvdtor) Warning LangEnabledBy(C++ ObjC++,Wall || Weffc+
|
|||
Warn about deleting polymorphic objects with non-virtual destructors.
|
||||
|
||||
Wdeprecated
|
||||
C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) CppReason(CPP_W_DEPRECATED) Var(warn_deprecated) Init(1) Warning
|
||||
Warn if a deprecated compiler feature, class, method, or field is used.
|
||||
C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) CppReason(CPP_W_DEPRECATED)
|
||||
; Documented in common.opt
|
||||
|
||||
Wdeprecated-copy
|
||||
C++ ObjC++ Var(warn_deprecated_copy) Warning LangEnabledBy(C++ ObjC++, Wextra)
|
||||
|
|
|
|||
|
|
@ -2872,12 +2872,16 @@ asm_clobber_reg_is_valid (int regno, int nregs, const char *regname)
|
|||
error ("PIC register clobbered by %qs in %<asm%>", regname);
|
||||
is_valid = false;
|
||||
}
|
||||
/* Clobbering the STACK POINTER register is an error. */
|
||||
if (overlaps_hard_reg_set_p (regset, Pmode, STACK_POINTER_REGNUM))
|
||||
{
|
||||
error ("Stack Pointer register clobbered by %qs in %<asm%>", regname);
|
||||
is_valid = false;
|
||||
}
|
||||
/* Clobbering the stack pointer register is deprecated. GCC expects
|
||||
the value of the stack pointer after an asm statement to be the same
|
||||
as it was before, so no asm can validly clobber the stack pointer in
|
||||
the usual sense. Adding the stack pointer to the clobber list has
|
||||
traditionally had some undocumented and somewhat obscure side-effects. */
|
||||
if (overlaps_hard_reg_set_p (regset, Pmode, STACK_POINTER_REGNUM)
|
||||
&& warning (OPT_Wdeprecated, "listing the stack pointer register"
|
||||
" %qs in a clobber list is deprecated", regname))
|
||||
inform (input_location, "the value of the stack pointer after an %<asm%>"
|
||||
" statement must be the same as it was before the statement");
|
||||
|
||||
return is_valid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -579,6 +579,10 @@ Wattribute-warning
|
|||
Common Var(warn_attribute_warning) Init(1) Warning
|
||||
Warn about uses of __attribute__((warning)) declarations.
|
||||
|
||||
Wdeprecated
|
||||
Common Var(warn_deprecated) Init(1) Warning
|
||||
Warn if a deprecated compiler feature, class, method, or field is used.
|
||||
|
||||
Wdeprecated-declarations
|
||||
Common Var(warn_deprecated_decl) Init(1) Warning
|
||||
Warn about uses of __attribute__((deprecated)) declarations.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
PR inline-asm/52813
|
||||
* lang.opt (Wdeprecated): Reference common.opt instead of c.opt.
|
||||
|
||||
2019-01-12 Iain Buclaw <ibuclaw@gdcproject.org>
|
||||
|
||||
* README.gcc: New file.
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ Warn about casts that will produce a null result.
|
|||
|
||||
Wdeprecated
|
||||
D
|
||||
; Documented in C
|
||||
; Documented in common.opt
|
||||
|
||||
Werror
|
||||
D
|
||||
|
|
|
|||
|
|
@ -9441,6 +9441,15 @@ When the compiler selects which registers to use to represent input and output
|
|||
operands, it does not use any of the clobbered registers. As a result,
|
||||
clobbered registers are available for any use in the assembler code.
|
||||
|
||||
Another restriction is that the clobber list should not contain the
|
||||
stack pointer register. This is because the compiler requires the
|
||||
value of the stack pointer to be the same after an @code{asm}
|
||||
statement as it was on entry to the statement. However, previous
|
||||
versions of GCC did not enforce this rule and allowed the stack
|
||||
pointer to appear in the list, with unclear semantics. This behavior
|
||||
is deprecated and listing the stack pointer may become an error in
|
||||
future versions of GCC@.
|
||||
|
||||
Here is a realistic example for the VAX showing the use of clobbered
|
||||
registers:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
2019-01-15 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
PR inline-asm/52813
|
||||
* gcc.target/i386/pr52813.c (test1): Turn the diagnostic into a
|
||||
-Wdeprecated warning and expect a following note:.
|
||||
|
||||
2019-01-15 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR debug/88046
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@
|
|||
void
|
||||
test1 (void)
|
||||
{
|
||||
asm volatile ("" : : : "%esp"); /* { dg-error "Stack Pointer register clobbered" } */
|
||||
asm volatile ("" : : : "%esp"); /* { dg-warning "listing the stack pointer register '%esp' in a clobber list is deprecated" } */
|
||||
/* { dg-message "note: the value of the stack pointer after an 'asm' statement must be the same as it was before the statement" "" { target *-*-* } .-1 } */
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue