This is the mail archive of the 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] Avoid ice-on-invalid in xref_basetypes (PR c++/34089)


xref_basetypes relies on the first argument being aggregate type,
but on invalid testcases like the attached one cp_parser_class_specifier
can contain various other types (in this case LANG_TYPE - a type
As begin_class_definition has all the needed code to report diagnostics
and have sane error recovery and cp_parser_class_specifier calls it shortly
after this, I think the best fix for this is instead of duplicating
such checks and error recovery just not call xref_basetypes for
non-aggregates at all and just let begin_class_definition do its job.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2007-11-19  Jakub Jelinek  <>

	PR c++/34089
	* parser.c (cp_parser_class_specifier): Don't call xref_basetypes
	if type is not aggregate type.

	* g++.dg/template/crash74.C: New test.

--- gcc/cp/parser.c.jj	2007-11-08 01:19:18.000000000 +0100
+++ gcc/cp/parser.c	2007-11-19 17:47:34.000000000 +0100
@@ -14134,7 +14134,7 @@ cp_parser_class_specifier (cp_parser* pa
   /* Process the base classes. If they're invalid, skip the 
      entire class body.  */
-  if (!xref_basetypes (type, bases))
+  if (IS_AGGR_TYPE (type) && !xref_basetypes (type, bases))
       /* Consuming the closing brace yields better error messages
          later on.  */
--- gcc/testsuite/g++.dg/template/crash74.C.jj	2007-11-19 17:53:27.000000000 +0100
+++ gcc/testsuite/g++.dg/template/crash74.C	2007-11-19 17:54:38.000000000 +0100
@@ -0,0 +1,6 @@
+// PR c++/34089
+// { dg-do compile }
+// { dg-options "" }
+template<typename F> void foo () { }
+template<typename F> struct foo<F> { };	// { dg-error "template class without a name|abstract decl" }


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