From dc442cef60468a813ab2abee691280089a5e5b7f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 27 Mar 2018 21:58:30 +0200 Subject: [PATCH] re PR c++/85076 (ICE with invalid template used as lambda argument) PR c++/85076 * tree.c (cp_build_reference_type): If to_type is error_mark_node, return it right away. * g++.dg/cpp1y/pr85076.C: New test. From-SVN: r258901 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/tree.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/pr85076.C | 6 ++++++ 4 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr85076.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f7f48879b6f..b410f3d003e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-03-27 Jakub Jelinek + + PR c++/85076 + * tree.c (cp_build_reference_type): If to_type is error_mark_node, + return it right away. + 2018-03-27 Volker Reichelt * search.c (check_final_overrider): Use inform instead of error diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index f1a90bdec0f..0355b9ed9c5 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1078,6 +1078,9 @@ cp_build_reference_type (tree to_type, bool rval) { tree lvalue_ref, t; + if (to_type == error_mark_node) + return error_mark_node; + if (TREE_CODE (to_type) == REFERENCE_TYPE) { rval = rval && TYPE_REF_IS_RVALUE (to_type); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b8d56f8532c..9cd81d9946b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-27 Jakub Jelinek + + PR c++/85076 + * g++.dg/cpp1y/pr85076.C: New test. + 2018-03-27 Thomas Koenig PR fortran/85084 diff --git a/gcc/testsuite/g++.dg/cpp1y/pr85076.C b/gcc/testsuite/g++.dg/cpp1y/pr85076.C new file mode 100644 index 00000000000..6d54dea6c01 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr85076.C @@ -0,0 +1,6 @@ +// PR c++/85076 +// { dg-do compile { target c++14 } } + +template struct A*; // { dg-error "expected unqualified-id before" } + +auto a = [](A) {}; // { dg-error "is not a template|has incomplete type" } -- 2.30.2