From: Jason Merrill Date: Fri, 8 Jan 2016 16:02:04 +0000 (-0500) Subject: re PR c++/66921 (failure to determine size of static constexpr array that is nested... X-Git-Tag: releases/gcc-4.9.4~411 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7294db557d531e9ec6b32be1bfe096d1d0e6104c;p=thirdparty%2Fgcc.git re PR c++/66921 (failure to determine size of static constexpr array that is nested within a templated class) PR c++/66921 * decl.c (cp_complete_array_type): Allow an initializer that already has array type. From-SVN: r232170 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 34e1ea241a66..821cee066c8f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-12-21 Jason Merrill + + PR c++/66921 + * decl.c (cp_complete_array_type): Allow an initializer that + already has array type. + 2015-12-17 Jason Merrill PR c++/67576 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 46cd58f95b93..65c78b7d2a02 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 index 000000000000..b8eb08411c1e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array14.C @@ -0,0 +1,9 @@ +// PR c++/66921 +// { dg-do compile { target c++11 } } + +template +struct Holder { + constexpr static const int array[] = { 1, 2, 3 }; + enum {F = array[0]}; +}; +class HI: public Holder {};