diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-08-31 02:49:42 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-08-31 02:49:42 +0000 |
commit | 08f3e2d6f732c5b3b27b6fbb81e277528cf4fde1 (patch) | |
tree | be5639ad1b8c19fb937e2d7bf7a4504ed26ce341 | |
parent | af16a88a4b5bb0b6f2520016e7d5a467a8239813 (diff) | |
download | gcc-08f3e2d6f732c5b3b27b6fbb81e277528cf4fde1.tar.gz |
* decl.c (cp_finish_decl): Check for invalid multiple initializers
even if the initializer is dependent.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190826 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/decl.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/static30.C | 2 |
3 files changed, 13 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2eca6785b26..1baeaf1a2b7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2012-08-30 Jason Merrill <jason@redhat.com> + * decl.c (cp_finish_decl): Check for invalid multiple initializers + even if the initializer is dependent. + * pt.c (instantiate_template_1): Keep processing_template_decl set if there are dependent args. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 4b2958c5eee..19485fc712c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6123,8 +6123,15 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, release_tree_vector (cleanups); } else if (!DECL_PRETTY_FUNCTION_P (decl)) - /* Deduce array size even if the initializer is dependent. */ - maybe_deduce_size_from_array_init (decl, init); + { + /* Deduce array size even if the initializer is dependent. */ + maybe_deduce_size_from_array_init (decl, init); + /* And complain about multiple initializers. */ + if (init && TREE_CODE (init) == TREE_LIST && TREE_CHAIN (init) + && !MAYBE_CLASS_TYPE_P (type)) + init = build_x_compound_expr_from_list (init, ELK_INIT, + tf_warning_or_error); + } if (init) DECL_INITIAL (decl) = init; diff --git a/gcc/testsuite/g++.dg/template/static30.C b/gcc/testsuite/g++.dg/template/static30.C index 01fa5dc1e0e..07dafe23ffa 100644 --- a/gcc/testsuite/g++.dg/template/static30.C +++ b/gcc/testsuite/g++.dg/template/static30.C @@ -7,4 +7,4 @@ template <int> struct A }; template <int N> const int A<N>::i1(A<N>::i); -template <int N> const int A<N>::i2(3, A<N>::i); +template <int N> const int A<N>::i2(3, A<N>::i); // { dg-error "expression list" } |