]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/66921 (failure to determine size of static constexpr array that is nested...
authorJason Merrill <jason@redhat.com>
Fri, 8 Jan 2016 16:02:04 +0000 (11:02 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 8 Jan 2016 16:02:04 +0000 (11:02 -0500)
PR c++/66921
* decl.c (cp_complete_array_type): Allow an initializer that
already has array type.

From-SVN: r232170

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

index 34e1ea241a66d5ad359ae903c89e2cadc8cc3e98..821cee066c8f3b75b0e7595622ccb3fa842c9a33 100644 (file)
@@ -1,3 +1,9 @@
+2015-12-21  Jason Merrill  <jason@redhat.com>
+
+       PR c++/66921
+       * decl.c (cp_complete_array_type): Allow an initializer that
+       already has array type.
+
 2015-12-17  Jason Merrill  <jason@redhat.com>
 
        PR c++/67576
index 46cd58f95b93364148f386926f28db29e8998507..65c78b7d2a02ecf0e9a17414c0d62bf978cf09f8 100644 (file)
@@ -7138,7 +7138,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> {};