diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7f911282626..ff696e3e884 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-01-30 Paolo Carlini + + PR c++/58649 + * pt.c (lookup_template_class_1): Check start_enum return value + for error_mark_node. + 2014-01-30 Paolo Carlini * decl.c (duplicate_decls, typename_hash, typename_compare): diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c9c6b379bf6..4a5b6cc0684 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7521,6 +7521,9 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, tsubst (ENUM_UNDERLYING_TYPE (template_type), arglist, complain, in_decl), SCOPED_ENUM_P (template_type), NULL); + + if (t == error_mark_node) + return t; } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 77953e9b395..ce37ff18139 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-01-30 Paolo Carlini + + PR c++/58649 + * g++.dg/template/crash117.C: New. + 2014-01-30 Richard Biener PR c/59905 diff --git a/gcc/testsuite/g++.dg/template/crash117.C b/gcc/testsuite/g++.dg/template/crash117.C new file mode 100644 index 00000000000..5aaaf7344f3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash117.C @@ -0,0 +1,9 @@ +// PR c++/58649 + +template void foo() +{ + E(); // { dg-error "declaration|declared" } + enum E {}; +} + +template void foo();