re PR c++/66921 (failure to determine size of static constexpr array that is nested...
authorJason Merrill <jason@redhat.com>
Tue, 22 Dec 2015 21:46:50 +0000 (16:46 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 22 Dec 2015 21:46:50 +0000 (16:46 -0500)
PR c++/66921
* decl.c (cp_complete_array_type): Allow an initializer that
already has array type.

From-SVN: r231914

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp0x/constexpr-array14.C [new file with mode: 0644]

index c081160f31656a705dfdb0a0a48f844e75b586a1..02aa9b5c2c6deabe227da4fd4d6aa92a36024ef8 100644 (file)
@@ -1,5 +1,9 @@
 2015-12-22  Jason Merrill  <jason@redhat.com>
 
+       PR c++/66921
+       * decl.c (cp_complete_array_type): Allow an initializer that
+       already has array type.
+
        PR c++/67257
        * parser.c (cp_parser_single_declaration): Reject a class template
        that also declares a variable.
index a14062bca0d2987ef8d9511d4a53c8114072929e..af5f2654003aaa159f81e7686c9aa785b245c98d 100644 (file)
@@ -7479,7 +7479,8 @@ cp_complete_array_type (tree *ptype, tree initial_value, bool do_default)
 
   /* Don't get confused by a CONSTRUCTOR for some other type.  */
   if (initial_value && TREE_CODE (initial_value) == CONSTRUCTOR
-      && !BRACE_ENCLOSED_INITIALIZER_P (initial_value))
+      && !BRACE_ENCLOSED_INITIALIZER_P (initial_value)
+      && TREE_CODE (TREE_TYPE (initial_value)) != ARRAY_TYPE)
     return 1;
 
   if (initial_value)
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array14.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array14.C
new file mode 100644 (file)
index 0000000..b8eb084
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/66921
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+struct Holder {
+  constexpr static const int array[] = { 1, 2, 3 };
+  enum {F = array[0]};
+};
+class HI: public Holder<int> {};