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: PR9829


This patch fixes PR9829, a 3.3 regression, whereby we were ICEing on
weird stuff produced by the old parser.  The new parser doesn't get
itself all confused like this, so the mainline doesn't have this bug.

Tested on i686-pc-linux-gnu, applied on the branch -- and the testcase
on the mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com

2003-02-25  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/9829
	* decl.c (grokdeclarator): Handle SCOPE_REFs whose second argument
	is a NAMESPACE_DECL.

2003-02-25  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/9829
	* g++.dg/parse/namespace1.C: New test.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.965.2.16
diff -c -5 -p -r1.965.2.16 decl.c
*** cp/decl.c	23 Feb 2003 14:19:47 -0000	1.965.2.16
--- cp/decl.c	26 Feb 2003 01:57:15 -0000
*************** grokdeclarator (declarator, declspecs, d
*** 10325,10334 ****
--- 10325,10342 ----
  		    }
  		  else
  		    ctype = cname;
  		}
  
+ 	      /* If the parser sees something like "void a::b" where
+ 		 "a::b" is a namespace, it will build a SCOPE_REF with
+ 		 a NAMESPACE_DECL, rather than an IDENTIFIER_NODE, as
+ 		 the second operand.  Since the SCOPE_REF is being
+ 		 used as a declarator, we recover from that here.  */
+ 	      if (TREE_CODE (TREE_OPERAND (decl, 1)) == NAMESPACE_DECL)
+ 		TREE_OPERAND (decl, 1) = DECL_NAME (TREE_OPERAND (decl, 1));
+ 
  	      if (ctype && TREE_CODE (TREE_OPERAND (decl, 1)) == TYPE_DECL
  		  && constructor_name_p (DECL_NAME (TREE_OPERAND (decl, 1)),
  					 ctype))
  		TREE_OPERAND (decl, 1) = constructor_name (ctype);
  	      next = &TREE_OPERAND (decl, 1);
Index: testsuite/g++.dg/parse/namespace1.C
===================================================================
RCS file: testsuite/g++.dg/parse/namespace1.C
diff -N testsuite/g++.dg/parse/namespace1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/namespace1.C	26 Feb 2003 01:57:15 -0000
***************
*** 0 ****
--- 1,10 ----
+ namespace a {
+     namespace b {
+         void foo();
+     }
+ }
+ 
+ void
+ a::b:foo() // { dg-error "" }
+ {
+ }


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