From f62a0ddd737a3faa3925ae211bd22fa8ca62c112 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 19 Apr 2018 18:09:45 +0000 Subject: [PATCH] re PR c++/84611 (ICE in operator[], at vec.h:826 (local_class_index())) /cp 2018-04-19 Paolo Carlini PR c++/84611 * pt.c (lookup_template_class_1): Check pushtag return value for error_mark_node. /testsuite 2018-04-19 Paolo Carlini PR c++/84611 * g++.dg/parse/crash68.C: New. From-SVN: r259505 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/crash68.C | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/parse/crash68.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4475b228c2e..e4c3deb26fb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-19 Paolo Carlini + + PR c++/84611 + * pt.c (lookup_template_class_1): Check pushtag return value for + error_mark_node. + 2018-04-19 Alexandre Oliva PR c++/80290 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 5d7060858b9..1370e21ad59 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9444,7 +9444,9 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, /* 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e7b9547c1a4..bff3cd6e995 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-04-19 Paolo Carlini + + PR c++/84611 + * g++.dg/parse/crash68.C: New. + 2018-04-19 H.J. Lu PR libgcc/85334 diff --git a/gcc/testsuite/g++.dg/parse/crash68.C b/gcc/testsuite/g++.dg/parse/crash68.C new file mode 100644 index 00000000000..8c1e4baa267 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash68.C @@ -0,0 +1,18 @@ +// PR c++/84611 + +template +struct a { + a() { + struct c; + try { + } catch (struct c {}) { // { dg-error "types may not be defined|conflicting" } + } + } +}; + +struct d { + d(); + a<> b; +}; + +d::d() {} -- 2.30.2