This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] volatile global register variable
>>>>> Mark Mitchell writes:
Mark> So, the patch is OK, once the documentation is added.
Appended is the revised patch that I believe addresses the
comments. I will check it in on Friday, unless I hear otherwise.
Thanks, David
PR 24644
* common.opt (Wvolatile-register-var): New.
* varasm.c (make_decl_rtl): Only emit warning when option
specified.
* doc/invoke.texi (Wvolatile-register-var): Document new option.
Index: common.opt
===================================================================
*** common.opt (revision 106727)
--- common.opt (working copy)
*************** Wunused-variable
*** 173,178 ****
--- 173,182 ----
Common Var(warn_unused_variable)
Warn when a variable is unused
+ Wvolatile-register-var
+ Common
+ Warn when a register variable is declared volatile
+
aux-info
Common Separate
-aux-info <file> Emit declaration information into <file>
Index: varasm.c
===================================================================
*** varasm.c (revision 106727)
--- varasm.c (working copy)
*************** make_decl_rtl (tree decl)
*** 955,962 ****
error ("global register variable has initial value");
}
if (TREE_THIS_VOLATILE (decl))
! warning (0, "volatile register variables don%'t "
! "work as you might wish");
/* If the user specified one of the eliminables registers here,
e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
--- 955,963 ----
error ("global register variable has initial value");
}
if (TREE_THIS_VOLATILE (decl))
! warning (OPT_Wvolatile_register_var,
! "optimization may eliminate reads and/or "
! "writes to register variables");
/* If the user specified one of the eliminables registers here,
e.g., FRAME_POINTER_REGNUM, we don't want to get this variable
Index: doc/invoke.texi
===================================================================
*** doc/invoke.texi (revision 106727)
--- doc/invoke.texi (working copy)
*************** Objective-C and Objective-C++ Dialects}.
*** 245,251 ****
-Wunknown-pragmas -Wno-pragmas -Wunreachable-code @gol
-Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol
-Wunused-value -Wunused-variable -Wvariadic-macros @gol
! -Wwrite-strings}
@item C-only Warning Options
@gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
--- 245,251 ----
-Wunknown-pragmas -Wno-pragmas -Wunreachable-code @gol
-Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol
-Wunused-value -Wunused-variable -Wvariadic-macros @gol
! -Wvolatile-register-var -Wwrite-strings}
@item C-only Warning Options
@gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
*************** only when @option{-pedantic} flag is use
*** 3369,3374 ****
--- 3369,3381 ----
Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
alternate syntax when in pedantic ISO C99 mode. This is default.
To inhibit the warning messages, use @option{-Wno-variadic-macros}.
+
+ @item -Wvolatile-register-var
+ @opindex Wvolatile-register-var
+ @opindex Wno-volatile-register-var
+ Warn if a register variable is declared volatile. The volatile
+ modifier does not inhibit all optimizations that may eliminate reads
+ and/or writes to register variables.
@item -Wdisabled-optimization
@opindex Wdisabled-optimization