diff options
author | Jason Merrill <jason@redhat.com> | 2010-04-01 14:48:46 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-04-01 14:48:46 -0400 |
commit | d4b5fb2238f98fedbf123d80714b2ab1b0ceff2d (patch) | |
tree | b877fd158644b9a63137f360f63f8d3c625c2990 | |
parent | 9542943db3fca29644fa2450523d8277e0a74f5f (diff) | |
download | gcc-d4b5fb2238f98fedbf123d80714b2ab1b0ceff2d.zip gcc-d4b5fb2238f98fedbf123d80714b2ab1b0ceff2d.tar.gz gcc-d4b5fb2238f98fedbf123d80714b2ab1b0ceff2d.tar.bz2 |
decl.c (next_initializable_field): No longer static.
* decl.c (next_initializable_field): No longer static.
* cp-tree.h: Declare it.
* call.c (build_aggr_conv): Fail if there are more initializers
than initializable fields.
From-SVN: r157927
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/call.c | 12 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist12.C | 7 |
6 files changed, 23 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d8ba37d..ee75c46 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2010-04-01 Jason Merrill <jason@redhat.com> + * decl.c (next_initializable_field): No longer static. + * cp-tree.h: Declare it. + * call.c (build_aggr_conv): Fail if there are more initializers + than initializable fields. + * semantics.c (maybe_add_lambda_conv_op): Use null_pointer_node instead of void_zero_node. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index edec6eaf..5a32b3b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -626,23 +626,27 @@ build_aggr_conv (tree type, tree ctor, int flags) { unsigned HOST_WIDE_INT i = 0; conversion *c; - tree field = TYPE_FIELDS (type); + tree field = next_initializable_field (TYPE_FIELDS (type)); - for (; field; field = TREE_CHAIN (field), ++i) + for (; field; field = next_initializable_field (TREE_CHAIN (field))) { - if (TREE_CODE (field) != FIELD_DECL) - continue; if (i < CONSTRUCTOR_NELTS (ctor)) { constructor_elt *ce = CONSTRUCTOR_ELT (ctor, i); if (!can_convert_arg (TREE_TYPE (field), TREE_TYPE (ce->value), ce->value, flags)) return NULL; + ++i; + if (TREE_CODE (type) == UNION_TYPE) + break; } else if (build_value_init (TREE_TYPE (field)) == error_mark_node) return NULL; } + if (i < CONSTRUCTOR_NELTS (ctor)) + return NULL; + c = alloc_conversion (ck_aggr); c->type = type; c->rank = cr_exact; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index fb67965..6334673 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4727,6 +4727,7 @@ extern bool cp_missing_noreturn_ok_p (tree); extern void initialize_artificial_var (tree, tree); extern tree check_var_type (tree, tree); extern tree reshape_init (tree, tree); +extern tree next_initializable_field (tree); extern bool defer_mark_used_calls; extern GTY(()) VEC(tree, gc) *deferred_mark_used_calls; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e38abda..a308d64 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -104,7 +104,6 @@ static tree build_cp_library_fn (tree, enum tree_code, tree); static void store_parm_decls (tree); static void initialize_local_var (tree, tree); static void expand_static_init (tree, tree); -static tree next_initializable_field (tree); /* The following symbols are subsumed in the cp_global_trees array, and listed here individually for documentation purposes. @@ -4723,7 +4722,7 @@ static tree reshape_init_r (tree, reshape_iter *, bool); initialized. If there are no more such fields, the return value will be NULL. */ -static tree +tree next_initializable_field (tree field) { while (field diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8c48a0b..9eef0b0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-04-01 Jason Merrill <jason@redhat.com> + + * g++.dg/cpp0x/initlist12.C: Adjust expected errors. + 2010-04-01 Janne Blomqvist <jb@gcc.gnu.org> Manfred Schwarb <manfred99@gmx.ch> diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist12.C b/gcc/testsuite/g++.dg/cpp0x/initlist12.C index 31d34c4..f344c78 100644 --- a/gcc/testsuite/g++.dg/cpp0x/initlist12.C +++ b/gcc/testsuite/g++.dg/cpp0x/initlist12.C @@ -1,20 +1,21 @@ // PR c++/38698 // { dg-options "-std=c++0x" } +// { dg-prune-output "note" } struct A { int i; }; -A a({1,2}); // { dg-error "too many initializers" } +A a({1,2}); // { dg-error "no match" } union U { int i,j; }; -U u({1,2}); // { dg-error "too many initializers" } +U u({1,2}); // { dg-error "no match" } union V {}; -V v({1}); // { dg-error "too many initializers" } +V v({1}); // { dg-error "no match" } |