PR c++/89532 - ICE with incomplete type in decltype.
authorMarek Polacek <polacek@redhat.com>
Fri, 1 Mar 2019 15:55:56 +0000 (15:55 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 1 Mar 2019 15:55:56 +0000 (15:55 +0000)
* semantics.c (finish_compound_literal): Return error_mark_node
if digest_init_flags returns error_mark_node.

* g++.dg/cpp2a/nontype-class14.C: New test.

From-SVN: r269317

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/nontype-class14.C [new file with mode: 0644]

index 11b9bb2dd9be086095c3df821a54b5647d6249b5..ae5fd563dc30382bee0330079f527be18f817e39 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/89532 - ICE with incomplete type in decltype.
+       * semantics.c (finish_compound_literal): Return error_mark_node
+       if digest_init_flags returns error_mark_node.
+
 2019-03-01  Jakub Jelinek  <jakub@redhat.com>
 
        Implement P1002R1, Try-catch blocks in constexpr functions
index d1a378acd98965fe3612540f1757af0ae4d79c23..c03e4ef247c51415f4bc6d562be1e1be2349d2af 100644 (file)
@@ -2859,6 +2859,9 @@ finish_compound_literal (tree type, tree compound_literal,
   compound_literal = digest_init_flags (type, compound_literal,
                                        LOOKUP_NORMAL | LOOKUP_NO_NARROWING,
                                        complain);
+  if (compound_literal == error_mark_node)
+    return error_mark_node;
+
   /* If we're in a template, return the original compound literal.  */
   if (orig_cl)
     {
index 7734ac679a5383ce2e24d2abb097186c1a5070d5..88cda1a9df24196833085dfec6d167a95bf8102d 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/89532 - ICE with incomplete type in decltype.
+       * g++.dg/cpp2a/nontype-class14.C: New test.
+
 2019-03-01  Jakub Jelinek  <jakub@redhat.com>
 
        Implement P1002R1, Try-catch blocks in constexpr functions
diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class14.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class14.C
new file mode 100644 (file)
index 0000000..9cc1446
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/89532
+// { dg-do compile { target c++2a } }
+
+struct tuple;
+
+template <decltype(tuple {})> // { dg-error "invalid use of incomplete type" }
+struct S { };
+
+template<typename>
+decltype(tuple {}) d; // { dg-error "invalid use of incomplete type" }