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:.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267941
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
+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
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)
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;
}
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.
+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.
Wdeprecated
D
-; Documented in C
+; Documented in common.opt
Werror
D
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:
+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
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 } */
}