diff options
author | Jason Merrill <jason@redhat.com> | 2008-07-02 11:38:50 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2008-07-02 11:38:50 -0400 |
commit | 0935784671e347118c6bf7629852ba50e9466a85 (patch) | |
tree | 607689dbfbc953af02e19c2cf6b60aa4ddae34e3 /gcc/tree.h | |
parent | 906c5773db6775e8182c4ff74f5c835bca66ae4e (diff) | |
download | gcc-0935784671e347118c6bf7629852ba50e9466a85.zip gcc-0935784671e347118c6bf7629852ba50e9466a85.tar.gz gcc-0935784671e347118c6bf7629852ba50e9466a85.tar.bz2 |
Implement WG21 N2672, Initializer List proposed wording
gcc/cp/ChangeLog:
2008-07-02 Jason Merrill <jason@redhat.com>
Implement WG21 N2672, Initializer List proposed wording
* cp-tree.h (enum cp_tree_index): Add CPTI_INIT_LIST_TYPE.
(struct lang_type_class): Add has_list_ctor bitfield.
(TYPE_HAS_LIST_CTOR): New macro.
(BRACE_ENCLOSED_INITIALIZER_P): Expect init_list_type_node.
(CONSTRUCTOR_IS_DIRECT_INIT): New macro.
(LOOKUP_NO_NARROWING): New macro.
(LOOKUP_NO_COPY_CTOR_CONVERSION): New macro.
* parser.c (cp_parse_braced_list): Split out from...
(cp_parser_initializer_clause): ...here.
(cp_parser_postfix_expression): Build up CONSTRUCTOR for compound
literal here.
(cp_lexer_next_token_is_not_keyword): New fn.
(cp_parser_parenthesized_expression_list): Handle { }.
(cp_parser_new_expression, cp_parser_new_initializer): Likewise.
(cp_parser_assignment_expression, cp_parser_condition): Likewise.
(cp_parser_jump_statement, cp_parser_simple_declaration): Likewise.
(cp_parser_mem_initializer, cp_parser_init_declarator): Likewise.
(cp_parser_initializer, cp_parser_functional_cast): Likewise.
(cp_parser_omp_for_loop, cp_parser_cache_group): Likewise.
(cp_parser_save_member_function_body): Likewise.
* call.c (conversion_kind): Add ck_list, ck_aggr.
(struct conversion): Add check_narrowing bitfield, conversion list.
(build_list_conv): New fn.
(build_aggr_conv): New fn.
(implicit_conversion): Call them.
(standard_conversion): Set check_narrowing if appropriate.
(add_function_candidate): Handle LOOKUP_NO_COPY_CTOR_CONVERSION.
(build_user_type_conversion_1): When converting from an init list,
we allow additional conversions except when calling a copy ctor.
(convert_like_real): Calling an explicit ctor for an init list is
ill-formed. Handle ck_list and ck_addr. Check narrowing.
(build_new_method_call): If CONSTRUCTOR_IS_DIRECT_INIT is set and
class doesn't have a list ctor, break the {} into a TREE_LIST.
(compare_ics): ck_list is better than other UDCs.
(set_up_extended_ref_temp): Split out from initialize_reference.
(is_std_init_list): New fn.
(is_list_ctor): New fn.
* decl.c (cxx_init_decl_processing): Create init_list_type_node.
(reshape_init_array_1): Pass it to build_constructor.
(reshape_init_class): Ditto.
(initialize_artificial_var): Pass the appropriate type.
(build_aggr_init_full_exprs): Split out from...
(check_initializer): ...here. Handle new semantics.
(build_init_list_var_init): New subroutine of check_initializer.
(grokdeclarator): Converting constructors can have more than one parm.
(grok_special_member_properties): Set TYPE_HAS_LIST_CTOR.
* init.c (expand_default_init): Only do digest_init for aggregates.
* rtti.c (tinfo_base_init): Pass init_list_type_node to
build_constructor_from_list.
(generic_initializer, ptr_initializer): Ditto.
(ptm_initializer, class_initializer): Ditto.
(get_pseudo_ti_init): Ditto.
* error.c (dump_type): Handle init_list_type_node.
(maybe_warn_cpp0x): New fn.
(maybe_varn_variadic_templates): Call it.
* cvt.c (ocp_convert): Handle conversion from { }.
* tree.c (build_array_of_n_type): New fn.
* typeck2.c (store_init_value): Use init_list_type_node.
(digest_init): Likewise.
(check_narrowing): New fn.
* semantics.c: (finish_compound_literal): Take CONSTRUCTOR instead
of vector of constructor elts. Handle non-aggregate types. Make
constant literals static.
* pt.c: (tsubst_copy_and_build): Adjust.
(unify): Handle { }.
* name-lookup.c (arg_assoc_type): Handle init_list_type_node.
gcc/ChangeLog:
2008-07-02 Jason Merrill <jason@redhat.com>
* tree.c (ctor_to_list): New fn.
* tree.h: Declare it.
(CONSTRUCTOR_ELT): New macro.
(CONSTRUCTOR_NELTS): New macro.
libstdc++-v3/ChangeLog:
2008-07-02 Jason Merrill <jason@redhat.com>
* libsupc++/initializer_list: New file.
* include/bits/stl_map.h (insert(initializer_list)): New method.
From-SVN: r137361
Diffstat (limited to 'gcc/tree.h')
-rw-r--r-- | gcc/tree.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1586,6 +1586,9 @@ struct tree_vec GTY(()) /* In a CONSTRUCTOR node. */ #define CONSTRUCTOR_ELTS(NODE) (CONSTRUCTOR_CHECK (NODE)->constructor.elts) +#define CONSTRUCTOR_ELT(NODE,IDX) \ + (VEC_index (constructor_elt, CONSTRUCTOR_ELTS (NODE), IDX)) +#define CONSTRUCTOR_NELTS(NODE) (VEC_length (constructor_elt, CONSTRUCTOR_ELTS (NODE))) /* Iterate through the vector V of CONSTRUCTOR_ELT elements, yielding the value of each element (stored within VAL). IX must be a scratch variable @@ -4475,6 +4478,10 @@ extern int fields_length (const_tree); extern bool initializer_zerop (const_tree); +/* Given a CONSTRUCTOR CTOR, return the elements as a TREE_LIST. */ + +extern tree ctor_to_list (tree); + /* Examine CTOR to discover: * how many scalar fields are set to nonzero values, and place it in *P_NZ_ELTS; |