public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Avoid ice-on-invalid in xref_basetypes (PR c++/34089)
@ 2007-11-20 10:14 Jakub Jelinek
  2007-11-20 11:43 ` Mark Mitchell
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2007-11-20 10:14 UTC (permalink / raw)
  To: Jason Merrill, Mark Mitchell; +Cc: gcc-patches

Hi!

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
of OVERLOAD).
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  <jakub@redhat.com>

	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" }

	Jakub

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-11-20 15:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-20 10:14 [C++ PATCH] Avoid ice-on-invalid in xref_basetypes (PR c++/34089) Jakub Jelinek
2007-11-20 11:43 ` Mark Mitchell
2007-11-20 16:57   ` [C++ PATCH] Avoid ice-on-invalid in xref_basetypes (PR c++/34089, take 2) Jakub Jelinek
2007-11-20 19:19     ` Mark Mitchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).