diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-21 17:48:39 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-21 17:48:39 +0000 |
commit | e6d8a6d58af6a8df4fe5070f9a02d36997939d71 (patch) | |
tree | d6a744d44d90ff41a7bd2e3a59eab8c0e83f3a93 /gcc | |
parent | c4c17cb1cad7fb38a8e75c7950aca0323ab4f9e4 (diff) | |
download | gcc-e6d8a6d58af6a8df4fe5070f9a02d36997939d71.tar.gz |
PR c++/14616
* decl.c (cp_finish_decl): Compute the size of arrays declared in
templates, if their type is non-dependent.
PR c++/14616
* g++.dg/init/array13.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79788 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/array13.C | 9 |
4 files changed, 24 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 654e6a37a86..8f5130663f3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-03-21 Mark Mitchell <mark@codesourcery.com> + + PR c++/14616 + * decl.c (cp_finish_decl): Compute the size of arrays declared in + templates, if their type is non-dependent. + 2004-03-19 Mark Mitchell <mark@codesourcery.com> * call.c (build_op_delete_call): Do not forget the placement diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b8a578f9ee0..0b802ff7578 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4711,6 +4711,10 @@ cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags) if (init && DECL_INITIAL (decl)) DECL_INITIAL (decl) = init; + if (TREE_CODE (decl) == VAR_DECL + && !DECL_PRETTY_FUNCTION_P (decl) + && !dependent_type_p (TREE_TYPE (decl))) + maybe_deduce_size_from_array_init (decl, init); goto finish_end0; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b53e941f162..2ec9fe62044 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-03-21 Mark Mitchell <mark@codesourcery.com> + + PR c++/14616 + * g++.dg/init/array13.C: New test. + 2004-03-20 Roger Sayle <roger@eyesopen.com> PR target/13889 diff --git a/gcc/testsuite/g++.dg/init/array13.C b/gcc/testsuite/g++.dg/init/array13.C new file mode 100644 index 00000000000..aa66e33acfc --- /dev/null +++ b/gcc/testsuite/g++.dg/init/array13.C @@ -0,0 +1,9 @@ +template <typename DisjointSet> +struct test_disjoint_set { + static void do_test() + { + unsigned int elts[] + = { 0, 1, 2, 3 }; + const int N = sizeof(elts)/sizeof(*elts); + } +}; |