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] PR 37087 (take 2)


Hi again,

this is the version, regtested x86_64-linux, which deals with the issue much earlier, in the parser. Interestingly, the two additional errors emitted for decl5.C by the patched GCC align it to ICC ;)

Ok for mainline?

Paolo.

/////////////
/cp
2008-08-12  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/37087
	* parser.c (cp_parser_class_head): Early return error_mark_node in
	case of global qualification of class name or qualified name that
	does not name a class.

/testsuite
2008-08-12  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/37087
	* g++.dg/template/crash80.C: New.
	* g++.old-deja/g++.other/decl5.C: Adjust.
Index: testsuite/g++.old-deja/g++.other/decl5.C
===================================================================
*** testsuite/g++.old-deja/g++.other/decl5.C	(revision 139007)
--- testsuite/g++.old-deja/g++.other/decl5.C	(working copy)
*************** struct A {
*** 16,22 ****
    int m;
    };
    struct Z;
!   expand me;
    void foo(struct A::e);
    void foo(struct A::z);  // { dg-warning "" } extra qualification
  };
--- 16,22 ----
    int m;
    };
    struct Z;
!   expand me;          // { dg-error "" } not name a type
    void foo(struct A::e);
    void foo(struct A::z);  // { dg-warning "" } extra qualification
  };
*************** namespace NMS
*** 71,77 ****
    };
  }
  
! NMS::D thing;
  void NMS::fn()
  {
    i = 3;
--- 71,77 ----
    };
  }
  
! NMS::D thing;         // { dg-error "" } not name a type
  void NMS::fn()
  {
    i = 3;
Index: testsuite/g++.dg/template/crash80.C
===================================================================
*** testsuite/g++.dg/template/crash80.C	(revision 0)
--- testsuite/g++.dg/template/crash80.C	(revision 0)
***************
*** 0 ****
--- 1,9 ----
+ // PR c++/37087
+ 
+ namespace a {
+   template <typename T> class Foo;
+ }
+ 
+ namespace b {
+   template <> class ::a::Foo<double> {}; // { dg-error "global qualification" }
+ }
Index: cp/parser.c
===================================================================
*** cp/parser.c	(revision 139007)
--- cp/parser.c	(working copy)
*************** cp_parser_class_head (cp_parser* parser,
*** 14981,14991 ****
    cp_parser_commit_to_tentative_parse (parser);
    /* Issue the error about the overly-qualified name now.  */
    if (qualified_p)
!     cp_parser_error (parser,
! 		     "global qualification of class name is invalid");
    else if (invalid_nested_name_p)
!     cp_parser_error (parser,
! 		     "qualified name does not name a class");
    else if (nested_name_specifier)
      {
        tree scope;
--- 14981,14997 ----
    cp_parser_commit_to_tentative_parse (parser);
    /* Issue the error about the overly-qualified name now.  */
    if (qualified_p)
!     {
!       cp_parser_error (parser,
! 		       "global qualification of class name is invalid");
!       return error_mark_node;
!     }
    else if (invalid_nested_name_p)
!     {
!       cp_parser_error (parser,
! 		       "qualified name does not name a class");
!       return error_mark_node;
!     }
    else if (nested_name_specifier)
      {
        tree scope;

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