diff options
author | Jason Merrill <jason@redhat.com> | 2015-12-22 16:46:50 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2015-12-22 16:46:50 -0500 |
commit | 56343945983971d8fac3d80bf8c06d9c2fb07ad6 (patch) | |
tree | fe7cde7bee77c04e90dcf5e889fdad8be6a5a583 /gcc | |
parent | dfc9c481360183f1b2c4914b66c4303babc04df1 (diff) | |
download | gcc-56343945983971d8fac3d80bf8c06d9c2fb07ad6.zip gcc-56343945983971d8fac3d80bf8c06d9c2fb07ad6.tar.gz gcc-56343945983971d8fac3d80bf8c06d9c2fb07ad6.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-array14.C | 9 |
3 files changed, 15 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c081160..02aa9b5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index a14062b..af5f265 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 0000000..b8eb084 --- /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<typename T> +struct Holder { + constexpr static const int array[] = { 1, 2, 3 }; + enum {F = array[0]}; +}; +class HI: public Holder<int> {}; |