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 to grokfield for c++/18698


We were being to aggressive about thinking that invalid code was trying to be an access declaration. Fixed by requiring the scope to be a type.

Tested x86_64-pc-linux-gnu, applied to trunk.
2006-06-30  Jason Merrill  <jason@redhat.com>

	PR c++/18698
	* decl2.c (grokfield): Only try to treat the decl as an access 
	declaration if the scope is a class.

Index: testsuite/g++.dg/parse/access10.C
===================================================================
*** testsuite/g++.dg/parse/access10.C	(revision 0)
--- testsuite/g++.dg/parse/access10.C	(revision 0)
***************
*** 0 ****
--- 1,13 ----
+ // PR c++/18698
+ // The compiler was giving an error message for invalid syntax
+ // that irrelevantly talked about using-declarations.
+ 
+ template<int> struct A
+ {
+     ::A~();			// { dg-bogus "using-declaration" }
+ };
+ 
+ // Instead of the bogus error we get 3 separate errors.
+ // { dg-error "no type" "" { target *-*-* } 5 }
+ // { dg-error "::" "" { target *-*-* } 5 }
+ // { dg-error "~" "" { target *-*-* } 5 }
Index: cp/decl2.c
===================================================================
*** cp/decl2.c	(revision 115086)
--- cp/decl2.c	(working copy)
*************** grokfield (const cp_declarator *declarat
*** 769,774 ****
--- 769,776 ----
    if (!declspecs->any_specifiers_p
        && declarator->kind == cdk_id
        && declarator->u.id.qualifying_scope
+       && TYPE_P (declarator->u.id.qualifying_scope)
+       && IS_AGGR_TYPE (declarator->u.id.qualifying_scope)
        && TREE_CODE (declarator->u.id.unqualified_name) == IDENTIFIER_NODE)
      /* Access declaration */
      return do_class_using_decl (declarator->u.id.qualifying_scope,

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