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]

C++ PATCH: Fix PR 7176


We added an error message in GCC 3.x about the meaning of names
changin during the definition of a class, as that is invalid.
Unfortunately, it fired more often than it should have.

In the new parser, this problem is fixed in a more elegant way, but
this way will do for the old parser.

Bootstrapped and tested on i686-pc-linux-gnu, applied on the mainline
and the branch.

-- 
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2002-10-14  Mark Mitchell  <mark@codesourcery.com>

	PR c++/7176
	* lex.c (do_identifier): Add another option for the parsing
	parameter.
	* parse.y (do_id): Use it.

2002-10-14  Mark Mitchell  <mark@codesourcery.com>

	PR c++/7176
	* g++.dg/parse/friend1.C: New test.
	* g++.old-deja/g++.pt/memtemp64.C: Adjust.

Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/lex.c,v
retrieving revision 1.265.2.2
diff -c -p -r1.265.2.2 lex.c
*** cp/lex.c	23 May 2002 17:57:44 -0000	1.265.2.2
--- cp/lex.c	14 Oct 2002 07:41:03 -0000
*************** do_identifier (token, parsing, args)
*** 1194,1200 ****
       tree args;
  {
    register tree id;
!   int lexing = (parsing == 1);
  
    if (! lexing)
      id = lookup_name (token, 0);
--- 1194,1200 ----
       tree args;
  {
    register tree id;
!   int lexing = (parsing == 1 || parsing == 3);
  
    if (! lexing)
      id = lookup_name (token, 0);
*************** do_identifier (token, parsing, args)
*** 1216,1222 ****
  
    /* Remember that this name has been used in the class definition, as per
       [class.scope0] */
!   if (id && parsing)
      maybe_note_name_used_in_class (token, id);
  
    if (id == error_mark_node)
--- 1216,1222 ----
  
    /* Remember that this name has been used in the class definition, as per
       [class.scope0] */
!   if (id && parsing && parsing != 3)
      maybe_note_name_used_in_class (token, id);
  
    if (id == error_mark_node)
Index: cp/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parse.y,v
retrieving revision 1.248.2.5.4.1
diff -c -p -r1.248.2.5.4.1 parse.y
*** cp/parse.y	1 Sep 2002 20:10:32 -0000	1.248.2.5.4.1
--- cp/parse.y	14 Oct 2002 07:41:03 -0000
*************** do_id:
*** 1507,1513 ****
  		     don't do_identifier; we only do that for unqualified
  		     identifiers.  */
  	          if (!lastiddecl || TREE_CODE (lastiddecl) != TREE_LIST)
! 		    $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
  		  else
  		    $$ = $<ttype>-1;
  		}
--- 1507,1513 ----
  		     don't do_identifier; we only do that for unqualified
  		     identifiers.  */
  	          if (!lastiddecl || TREE_CODE (lastiddecl) != TREE_LIST)
! 		    $$ = do_identifier ($<ttype>-1, 3, NULL_TREE);
  		  else
  		    $$ = $<ttype>-1;
  		}
Index: testsuite/g++.dg/parse/friend1.C
===================================================================
RCS file: testsuite/g++.dg/parse/friend1.C
diff -N testsuite/g++.dg/parse/friend1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/friend1.C	14 Oct 2002 07:41:05 -0000
***************
*** 0 ****
--- 1,9 ----
+ namespace N {
+   template <typename T>
+   static void f ();
+ 
+   struct S {
+     friend void N::f<int> ();
+     static void f (int);
+   };
+ }
Index: testsuite/g++.old-deja/g++.pt/memtemp64.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.pt/memtemp64.C,v
retrieving revision 1.3
diff -c -p -r1.3 memtemp64.C
*** testsuite/g++.old-deja/g++.pt/memtemp64.C	19 Mar 2000 05:17:20 -0000	1.3
--- testsuite/g++.old-deja/g++.pt/memtemp64.C	14 Oct 2002 07:41:05 -0000
*************** template <class T>
*** 4,10 ****
  struct S1 {};
  
  template <class T>
! void f(T); // ERROR - original declaration.
  
  template <class C>
  struct S2
--- 4,10 ----
  struct S1 {};
  
  template <class T>
! void f(T);
  
  template <class C>
  struct S2


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