This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] C++ implications of PR 18160


Mark Mitchell writes:
> OK.

I had some merge conflicts with 

2004-11-09  Joseph S. Myers  <joseph@codesourcery.com> 
 
        * call.c, class.c, decl.c, decl2.c, error.c, mangle.c, parser.c, 
        pt.c, search.c, semantics.c, typeck.c: Use %q, %< and %> for 
        quoting in diagnostics. 
        * parser.c (cp_parser_sizeof_operand): Use '' instead of `' for 
        quoting in printf format. 
        * decl.c (duplicate_decls, start_decl): Use %qD instead of 
        unquoted %D. 

So this is what I've checked in.  (I had to update typeck.c and the
second testcase.)

Adam

        PR middle-end/18160   
        * typeck.c (cxx_mark_addressable): Issue an error if address of an 
        explicit register variable is requested. 

        PR middle-end/18160   
        * g++.dg/warn/register-var-1.C: New test. 
        * g++.dg/warn/register-var-2.C: New test. 

Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.594
diff -c -p -r1.594 typeck.c
*** cp/typeck.c	9 Nov 2004 10:12:43 -0000	1.594
--- cp/typeck.c	10 Nov 2004 21:04:38 -0000
*************** cxx_mark_addressable (tree exp)
*** 4343,4351 ****
        case CONST_DECL:
        case RESULT_DECL:
  	if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x)
! 	    && !DECL_ARTIFICIAL (x) && extra_warnings)
! 	  warning ("address requested for %qD, which is declared %<register%>",
!                    x);
  	TREE_ADDRESSABLE (x) = 1;
  	return true;
  
--- 4343,4358 ----
        case CONST_DECL:
        case RESULT_DECL:
  	if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x)
! 	    && !DECL_ARTIFICIAL (x))
! 	  if (DECL_HARD_REGISTER (x) != 0)
! 	    {
! 	      error
! 		("address of explicit register variable %qD requested", x);
! 	      return false;
! 	    }
! 	  else if (extra_warnings)
! 	    warning
! 	      ("address requested for %qD, which is declared %<register%>", x);
  	TREE_ADDRESSABLE (x) = 1;
  	return true;
  
Index: testsuite/g++.dg/warn/register-var-1.C
===================================================================
RCS file: testsuite/g++.dg/warn/register-var-1.C
diff -N testsuite/g++.dg/warn/register-var-1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/warn/register-var-1.C	10 Nov 2004 21:04:38 -0000
***************
*** 0 ****
--- 1,14 ----
+ /* PR/18160 */
+ 
+ /* { dg-do compile { target i?86-*-* } } */
+ 
+ /* This should yield an error even without -pedantic.  */
+ /* { dg-options "-ansi" } */
+ 
+ void g(int *);
+ 
+ void f(void) 
+ { 
+   register int x __asm ("eax");
+   g(&x);	/* { dg-error "error: address of explicit register variable" } */
+ } 
Index: testsuite/g++.dg/warn/register-var-2.C
===================================================================
RCS file: testsuite/g++.dg/warn/register-var-2.C
diff -N testsuite/g++.dg/warn/register-var-2.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/warn/register-var-2.C	10 Nov 2004 21:04:38 -0000
***************
*** 0 ****
--- 1,14 ----
+ /* PR/18160 */
+ 
+ /* { dg-do compile } */
+ 
+ /* This should yield an error even without -pedantic.  */
+ /* { dg-options "-Wall -W" } */
+ 
+ void g(int *);
+ 
+ void f(void) 
+ { 
+   register int x;
+   g(&x); /* { dg-warning "address requested for 'x', which is declared 'register'" } */
+ } 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]