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.carl...@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.carl...@oracle.com>
PR c++/84611
* g++.dg/parse/crash68.C: New.
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() {}