diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-15 16:32:38 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-15 16:32:38 +0000 |
commit | 6facde95827a410469645e9d58d106bdfdf49212 (patch) | |
tree | ebfcdd2df5f06eedf27dc62369acb9819a987cdf /gcc/cp/semantics.c | |
parent | 5fd049b720091358fb6722bef6bf3078c3329977 (diff) |
PR c++/78358 - tuple decomposition decltype
* semantics.c (finish_decltype_type): Strip references for a tuple
decomposition.
* cp-tree.h (DECL_DECOMPOSITION_P): False for non-variables.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242432 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 29f52333a94..dc5ad13f681 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8873,14 +8873,6 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, if (identifier_p (expr)) expr = lookup_name (expr); - /* The decltype rules for decomposition are different from the rules for - member access; in particular, the decomposition decl gets - cv-qualifiers from the aggregate object, whereas decltype of a member - access expr ignores the object. */ - if (VAR_P (expr) && DECL_DECOMPOSITION_P (expr) - && DECL_HAS_VALUE_EXPR_P (expr)) - return unlowered_expr_type (DECL_VALUE_EXPR (expr)); - if (INDIRECT_REF_P (expr)) /* This can happen when the expression is, e.g., "a.b". Just look at the underlying operand. */ @@ -8898,6 +8890,21 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, /* See through BASELINK nodes to the underlying function. */ expr = BASELINK_FUNCTIONS (expr); + /* decltype of a decomposition name drops references in the tuple case + (unlike decltype of a normal variable) and keeps cv-qualifiers from + the containing object in the other cases (unlike decltype of a member + access expression). */ + if (DECL_DECOMPOSITION_P (expr)) + { + if (DECL_HAS_VALUE_EXPR_P (expr)) + /* Expr is an array or struct subobject proxy, handle + bit-fields properly. */ + return unlowered_expr_type (expr); + else + /* Expr is a reference variable for the tuple case. */ + return non_reference (TREE_TYPE (expr)); + } + switch (TREE_CODE (expr)) { case FIELD_DECL: |