]> 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>
Fri, 22 Jun 2018 21:01:00 +0000 (23:01 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Jun 2018 21:01:00 +0000 (23:01 +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: r261941

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

index 43cfb6c5b4aa956d9314cfbcdc69cb17856d6d06..5e4231ab8c1d47dfe57f1226cf377885baaa7de4 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 e6e05c1f8f7dfd94142a91c196eba36f1a84daa2..3b25ab92a1573ba598954421bac65cd3629c809e 100644 (file)
@@ -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);
index 0a04fd6ce91b82f6f44cefa761a1fbee7709eb52..fbd33d85f3b1cd87939cfe07edf4ed4fce330e5d 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" }