From 78b745b6808e7cc29d1dd357b0d0c25474a358ea Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 22 Jun 2018 23:01:00 +0200 Subject: [PATCH] backport: re PR c++/85076 (ICE with invalid template used as lambda argument) Backported from mainline 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. * g++.dg/cpp1y/pr85076.C: New test. From-SVN: r261941 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/tree.c | 3 +++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp1y/pr85076.C | 6 ++++++ 4 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr85076.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 43cfb6c5b4aa..5e4231ab8c1d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -3,6 +3,10 @@ Backported from mainline 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. + PR c++/85068 * class.c (update_vtable_entry_for_fn): Don't ICE if base_binfo is NULL. Assert if thunk_binfo is NULL then errorcount is non-zero. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index e6e05c1f8f7d..3b25ab92a157 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1050,6 +1050,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 0a04fd6ce91b..fbd33d85f3b1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,9 @@ Backported from mainline 2018-03-27 Jakub Jelinek + PR c++/85076 + * g++.dg/cpp1y/pr85076.C: New test. + PR c++/85068 * g++.dg/inherit/covariant22.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp1y/pr85076.C b/gcc/testsuite/g++.dg/cpp1y/pr85076.C new file mode 100644 index 000000000000..6d54dea6c018 --- /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.47.2