]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/85076 (ICE with invalid template used as lambda argument)
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 17:40:52 +0000 (19:40 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 17:40:52 +0000 (19:40 +0200)
Backported from mainline
2018-03-27  Jakub Jelinek  <jakub@redhat.com>

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: r262087

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/pr85076.C [new file with mode: 0644]

index 92171f91b91129042e4eaf33b28886de4edd515d..7b8d599ed5f61cbd603ac90f8d6b93ad1e8e3090 100644 (file)
@@ -3,6 +3,10 @@
        Backported from mainline
        2018-03-27  Jakub Jelinek  <jakub@redhat.com>
 
+       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.
index 8077e9ae3e827f98b6a277780bddc2cef472ec67..a861e51674a48a6c04d58c60d8d61e941b78722c 100644 (file)
@@ -962,6 +962,10 @@ tree
 cp_build_reference_type (tree to_type, bool rval)
 {
   tree lvalue_ref, t;
+
+  if (to_type == error_mark_node)
+    return error_mark_node;
+
   lvalue_ref = build_reference_type (to_type);
   if (!rval)
     return lvalue_ref;
index 3eef4e304fb5e8b9ddf4dfc36bffa76ef502299b..b69b29e407918458385f91346073807eaca1c659 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2018-03-27  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..6d54dea
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/85076
+// { dg-do compile { target c++14 } }
+
+template<typename> struct A*;  // { dg-error "expected unqualified-id before" }
+
+auto a = [](A<auto>) {};       // { dg-error "is not a template|has incomplete type" }