C++ PATCH: PR 10749 on mainline

Mark Mitchell mark@codesourcery.com
Fri Jun 20 19:26:00 GMT 2003


This patch fixes PR c++/10749 on the mainline.  Although the same test
case also fails to compile on the 3.3 branch, the root cause of the
problem is substantially different, so an entirely different patch
will be required there.  (In fact, my instinct is that we will declare
this problem unfixable on the 3.3 branch; it probably has to do with
limitations in the old parser, but I've yet to confirm that.)

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

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2003-06-20  Mark Mitchell  <mark@codesourcery.com>

	PR c++/10749
	* parser.c (cp_parser_class_head): See through dependent names
	when parsing a class-head.

2003-06-20  Mark Mitchell  <mark@codesourcery.com>

	PR c++/10749
	* g++.dg/template/memclass2.C: New test.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.64
diff -c -5 -p -r1.64 parser.c
*** cp/parser.c	16 Jun 2003 13:15:37 -0000	1.64
--- cp/parser.c	20 Jun 2003 18:49:42 -0000
*************** cp_parser_class_head (cp_parser* parser,
*** 11632,11642 ****
    /* Determine the name of the class.  Begin by looking for an
       optional nested-name-specifier.  */
    nested_name_specifier 
      = cp_parser_nested_name_specifier_opt (parser,
  					   /*typename_keyword_p=*/false,
! 					   /*check_dependency_p=*/true,
  					   /*type_p=*/false);
    /* If there was a nested-name-specifier, then there *must* be an
       identifier.  */
    if (nested_name_specifier)
      {
--- 11632,11642 ----
    /* Determine the name of the class.  Begin by looking for an
       optional nested-name-specifier.  */
    nested_name_specifier 
      = cp_parser_nested_name_specifier_opt (parser,
  					   /*typename_keyword_p=*/false,
! 					   /*check_dependency_p=*/false,
  					   /*type_p=*/false);
    /* If there was a nested-name-specifier, then there *must* be an
       identifier.  */
    if (nested_name_specifier)
      {
Index: testsuite/g++.dg/template/memclass2.C
===================================================================
RCS file: testsuite/g++.dg/template/memclass2.C
diff -N testsuite/g++.dg/template/memclass2.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/memclass2.C	20 Jun 2003 18:51:00 -0000
***************
*** 0 ****
--- 1,20 ----
+ namespace ns {
+   template<typename T>
+   struct Foo {
+     template<typename U> struct Bar;
+   };
+   
+   template<typename T>
+   template<typename U>
+   struct Foo<T>::Bar {
+     template<typename V> struct Baz;
+   };
+   
+   template<typename T>
+   template<typename U>
+   template<typename V>
+   struct Foo<T>::Bar<U>::Baz {
+     Foo<T> chokes;
+     ns::Foo<T> works;
+   };
+ }



More information about the Gcc-patches mailing list