diff mbox series

[C++] PR 84611 ("[6/7/8 Regression] ICE in operator[], at vec.h:826 (local_class_index())")

Message ID 1d1c94a7-3b20-47b8-b477-aee3ac66bf35@oracle.com
State New
Headers show
Series [C++] PR 84611 ("[6/7/8 Regression] ICE in operator[], at vec.h:826 (local_class_index())") | expand

Commit Message

Paolo Carlini April 19, 2018, 8:25 a.m. UTC
Hi,

the below is a rather low-key fix for this error-recovery regression: 
simply notice that pushtag is returning error_mark_node and avoid ICEing 
later. IMHO opinion it's correct and we may as well have it for 8.1.0 
but looking forward we really want a single error in such cases, 
probably by checking first the return value of 
cp_parser_check_type_definition in cp_parser_class_specifier_1. 
Unfortunately, not regressing in terms of error-recovery quality on, 
say, g++.old-deja/g++.jason/cond.C or g++.dg/parse/no-type-defn1.C seems 
pretty tough, I don't think it's 8.1.0 material. Tested x86-64-linux.

Thanks! Paolo.

/////////////////////
/cp
2018-04-19  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84611
	* pt.c (lookup_template_class_1): Check pushtag return value for
	error_mark_node.

/testsuite
2018-04-19  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84611
	* g++.dg/parse/crash68.C: New.

Comments

Jason Merrill April 19, 2018, 1:44 p.m. UTC | #1
Ok.

On Thu, Apr 19, 2018, 2:25 AM Paolo Carlini <paolo.carlini@oracle.com>
wrote:

> Hi,
>
> the below is a rather low-key fix for this error-recovery regression:
> simply notice that pushtag is returning error_mark_node and avoid ICEing
> later. IMHO opinion it's correct and we may as well have it for 8.1.0
> but looking forward we really want a single error in such cases,
> probably by checking first the return value of
> cp_parser_check_type_definition in cp_parser_class_specifier_1.
> Unfortunately, not regressing in terms of error-recovery quality on,
> say, g++.old-deja/g++.jason/cond.C or g++.dg/parse/no-type-defn1.C seems
> pretty tough, I don't think it's 8.1.0 material. Tested x86-64-linux.
>
> Thanks! Paolo.
>
> /////////////////////
>
>
diff mbox series

Patch

Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 259462)
+++ cp/pt.c	(working copy)
@@ -9444,7 +9444,9 @@  lookup_template_class_1 (tree d1, tree arglist, tr
 
 	  /* A local class.  Make sure the decl gets registered properly.  */
 	  if (context == current_function_decl)
-	    pushtag (DECL_NAME (gen_tmpl), t, /*tag_scope=*/ts_current);
+	    if (pushtag (DECL_NAME (gen_tmpl), t, /*tag_scope=*/ts_current)
+		== error_mark_node)
+	      return error_mark_node;
 
 	  if (comp_template_args (CLASSTYPE_TI_ARGS (template_type), arglist))
 	    /* This instantiation is another name for the primary
Index: testsuite/g++.dg/parse/crash68.C
===================================================================
--- testsuite/g++.dg/parse/crash68.C	(nonexistent)
+++ testsuite/g++.dg/parse/crash68.C	(working copy)
@@ -0,0 +1,18 @@ 
+// PR c++/84611
+
+template<typename = int>
+struct a {
+  a() {
+    struct c;
+    try {
+    } catch (struct c {}) {  // { dg-error "types may not be defined|conflicting" }
+    }
+  }
+};
+
+struct d {
+  d();
+  a<> b;
+};
+
+d::d() {}