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.
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;
};
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" }