c++: Handle bad pack expansion in base list. [PR96752]
authorNicholas Krause <xerofoify@gmail.com>
Tue, 23 Jun 2020 19:47:37 +0000 (15:47 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 24 Jun 2020 20:07:52 +0000 (16:07 -0400)
This fixes PR95672 by adding the missing TYPE_PACK_EXPANSION case in
cxx_incomplete_type_diagnostic in order to avoid ICEs on diagnosing
incomplete template pack expansion cases.

Tested on powerpc64le-unknown-linux-gnu.

gcc/cp/ChangeLog:

PR c++/95672
* typeck2.c (cxx_incomplete_type_diagnostic): Add missing
TYPE_EXPANSION_PACK check for diagnosing incomplete types in
cxx_incomplete_type_diagnostic.

gcc/testsuite/ChangeLog:

PR c++/95672
* g++.dg/template/pr95672.C: New test.

Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
gcc/cp/typeck2.c
gcc/testsuite/g++.dg/template/pr95672.C [new file with mode: 0644]

index 5fd3b82..dac135a 100644 (file)
@@ -552,6 +552,11 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
                       TYPE_NAME (type));
       break;
 
+    case TYPE_PACK_EXPANSION:
+      emit_diagnostic (diag_kind, loc, 0,
+                      "invalid use of pack expansion %qT", type);
+      break;
+
     case TYPENAME_TYPE:
     case DECLTYPE_TYPE:
       emit_diagnostic (diag_kind, loc, 0,
diff --git a/gcc/testsuite/g++.dg/template/pr95672.C b/gcc/testsuite/g++.dg/template/pr95672.C
new file mode 100644 (file)
index 0000000..c752b4a
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/95672
+// { dg-do compile { target c++14 } }
+struct g_class : decltype  (auto) ... {  }; // { dg-error "invalid use of pack expansion" }