From 56343945983971d8fac3d80bf8c06d9c2fb07ad6 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 22 Dec 2015 16:46:50 -0500 Subject: [PATCH] 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: r231914 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/decl.c | 3 ++- gcc/testsuite/g++.dg/cpp0x/constexpr-array14.C | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-array14.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c081160f316..02aa9b5c2c6 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 a14062bca0d..af5f2654003 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 00000000000..b8eb08411c1 --- /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 {}; -- 2.30.2