diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-11-14 06:02:58 +0100 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-11-14 00:02:58 -0500 |
commit | 70f40fea6a317d7be82d1f02defb59381c7752e7 (patch) | |
tree | dc50db5d9b8178d8b61bbce0247a6a9df671c429 /gcc/cp/tree.c | |
parent | e7555e42d0143f2a5ee50425902abde7c5091ad3 (diff) | |
download | gcc-70f40fea6a317d7be82d1f02defb59381c7752e7.zip gcc-70f40fea6a317d7be82d1f02defb59381c7752e7.tar.gz gcc-70f40fea6a317d7be82d1f02defb59381c7752e7.tar.bz2 |
Implement P0217R3 - C++17 structured bindings
gcc/
* match.pd: Don't try to compare addresses of variables with
DECL_VALUE_EXPR.
gcc/cp/
* cp-tree.h (struct lang_decl_base): Add decomposition_p.
(DECL_DECOMPOSITION_P): New
(enum auto_deduction_context): Add adc_decomp_type.
(enum cp_declarator_kind): Add cdk_decomp.
* constexpr.c (cxx_eval_constant_expression): Look through
DECL_VALUE_EXPR.
(potential_constant_expression_1): Likewise.
* decl.c (reshape_init): Preserve CONSTRUCTOR_IS_DIRECT_INIT.
(check_initializer): Use build_aggr_init for DECL_DECOMPOSITION_P.
(cp_finish_decl): Pass adc_decomp_type for decomposition.
(find_decomp_class_base, get_tuple_size, get_tuple_element_type)
(get_tuple_decomp_init, cp_finish_decomp): New.
(grokdeclarator): Handle decomposition.
* init.c (build_aggr_init): Handle decomposition array.
(build_vec_init): Handle initialization from { array }.
* name-lookup.c (add_function): Always wrap TEMPLATE_DECL in
OVERLOAD.
* parser.c (declarator_can_be_parameter_pack): Handle cdk_decomp.
(function_declarator_p, strip_declarator_types)
(cp_parser_check_declarator_template_parameters): Likewise.
(cp_parser_range_for, cp_convert_range_for): Handle decomposition.
(cp_parser_simple_declaration): Parse decomposition.
(cp_parser_decomposition_declaration): New.
* pt.c (tsubst_decomp_names): New.
(subst_expr) [DECL_EXPR, RANGE_FOR_STMT]: Handle decomposition.
(do_auto_deduction): Handle adc_decomp_type.
* semantics.c (finish_decltype_type): Look through DECL_VALUE_EXPR.
* typeck.c (is_bitfield_expr_with_lowered_type): Likewise.
* tree.c (lvalue_kind): Likewise.
(cp_build_reference_type): Handle reference collapsing.
Co-Authored-By: Jason Merrill <jason@redhat.com>
From-SVN: r242377
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r-- | gcc/cp/tree.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 7872dd2..c595437 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -142,6 +142,9 @@ lvalue_kind (const_tree ref) return clk_none; /* FALLTHRU */ case VAR_DECL: + if (DECL_HAS_VALUE_EXPR_P (ref)) + return lvalue_kind (DECL_VALUE_EXPR (CONST_CAST_TREE (ref))); + if (TREE_READONLY (ref) && ! TREE_STATIC (ref) && DECL_LANG_SPECIFIC (ref) && DECL_IN_AGGR_P (ref)) @@ -1012,6 +1015,13 @@ tree cp_build_reference_type (tree to_type, bool rval) { tree lvalue_ref, t; + + if (TREE_CODE (to_type) == REFERENCE_TYPE) + { + rval = rval && TYPE_REF_IS_RVALUE (to_type); + to_type = TREE_TYPE (to_type); + } + lvalue_ref = build_reference_type (to_type); if (!rval) return lvalue_ref; |