From: jason Date: Tue, 22 Dec 2015 21:46:50 +0000 (+0000) Subject: PR c++/66921 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=612a610dff37b37a7cdd8e92c8d65766724b58d6;p=thirdparty%2Fgcc.git PR c++/66921 * decl.c (cp_complete_array_type): Allow an initializer that already has array type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231914 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c081160f3165..02aa9b5c2c6d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2015-12-22 Jason Merrill + 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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index a14062bca0d2..af5f2654003a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 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 {};