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 7721 and PR 7803


This patchlet (developed against branch) fixes the PRs 7721 and 7803.
Bootstrapped with no regression on an i686-pc-linux-gnu

OK for mainline and branch?

-- Gaby
2002-10-09  Gabriel Dos Reis  <gdr@integrable-solutions.net>

	PRs C++/7721 and C++/7803
	* decl.c (grokdeclarator): Gracefully handle template-name as
	decl-specifier. 

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.866.2.36.2.2
diff -p -r1.866.2.36.2.2 decl.c
*** cp/decl.c	6 Oct 2002 23:02:09 -0000	1.866.2.36.2.2
--- cp/decl.c	9 Oct 2002 00:01:30 -0000
*************** grokdeclarator (declarator, declspecs, d
*** 10072,10077 ****
--- 10072,10086 ----
  	    next = 0;
  	    break;
  
+ 	  case TEMPLATE_DECL:
+ 	    /* Sometimes, we see a template-name used as part of a 
+ 	       decl-specifier like in 
+ 	             std::allocator alloc;
+                Handle that gracefully.  */
+ 	    error ("invalid use of template-name '%E' in a declarator", decl);
+ 	    return error_mark_node;
+ 	    break;
+ 
  	  default:
  	    internal_error ("`%D' as declarator", decl);
  	  }
Index: testsuite/g++.dg/parse/decl-specifier-1.C
===================================================================
RCS file: testsuite/g++.dg/parse/decl-specifier-1.C
diff -N testsuite/g++.dg/parse/decl-specifier-1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/decl-specifier-1.C	9 Oct 2002 00:01:39 -0000
***************
*** 0 ****
--- 1,16 ----
+ // Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
+ // Origin: PRs 7721 and 7803
+ // { dg-do compile }
+ 
+ namespace N
+ {
+     template<typename> 
+     struct X { };
+ }
+ 
+ N::X X;                           // { dg-error "invalid" "" }
+ 
+ int main()
+ {
+     return sizeof(X);             // { dg-error "" "" }
+ }


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