[PATCH] volatile global register variable

David Edelsohn dje@watson.ibm.com
Wed Nov 9 16:28:00 GMT 2005


	GCC currently generates a warning when one declares a global
register variable as volatile.  The warning cannot be disabled and is
rather uninformative: "don't work as you wish".

	With the new Tree-SSA infrastructure, there now are times when one
needs to declare a variable associated with a global register as volatile.
This patch changes the warning to be protected by an option and disabled
by default.  The warning could be enabled with -Wall, if that is desired.

Okay for mainline?

Thanks, David


	PR 24644
	* common.opt (Wvolatile-register-var): New.
	* varasm.c (make_decl_rtl): Only emit warning when option
	specified.

Index: common.opt
===================================================================
*** common.opt	(revision 106675)
--- 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 106675)
--- varasm.c	(working copy)
*************** make_decl_rtl (tree decl)
*** 955,961 ****
  	      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,
--- 955,962 ----
  	      error ("global register variable has initial value");
  	    }
  	  if (TREE_THIS_VOLATILE (decl))
! 	    warning (OPT_Wvolatile_register_var,
! 		     "volatile register variables don%'t "
  		     "work as you might wish");
  
  	  /* If the user specified one of the eliminables registers here,



More information about the Gcc-patches mailing list