PR c++/79607 - ICE with T{} initializer
authorJason Merrill <jason@redhat.com>
Mon, 20 Feb 2017 06:06:03 +0000 (01:06 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 20 Feb 2017 06:06:03 +0000 (01:06 -0500)
* decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR.

From-SVN: r245592

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/template/init11.C [new file with mode: 0644]

index 8ff836e..3ae8893 100644 (file)
@@ -1,5 +1,8 @@
 2017-02-19  Jason Merrill  <jason@redhat.com>
 
+       PR c++/79607 - ICE with T{} initializer
+       * decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR.
+
        PR c++/79566 - elaborated-type-specifier in range for
        * parser.c (cp_parser_simple_declaration): Fix check for type
        definition.
index 70c44fb..e5c2bab 100644 (file)
@@ -6662,6 +6662,9 @@ type_dependent_init_p (tree init)
   else if (TREE_CODE (init) == CONSTRUCTOR)
   /* A brace-enclosed initializer, e.g.: int i = { 3 }; ? */
     {
+      if (dependent_type_p (TREE_TYPE (init)))
+       return true;
+
       vec<constructor_elt, va_gc> *elts;
       size_t nelts;
       size_t i;
diff --git a/gcc/testsuite/g++.dg/template/init11.C b/gcc/testsuite/g++.dg/template/init11.C
new file mode 100644 (file)
index 0000000..ef337c0
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/79607
+// { dg-do compile { target c++11 } }
+
+template<typename T> struct A
+{
+  static const int i = int{T{}};
+};
+
+A<int> a;