diff options
author | Jason Merrill <jason@redhat.com> | 2013-04-15 15:26:12 +0000 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2013-04-15 15:26:12 +0000 |
commit | 97ebf79782d43f0d4a3a6d948667a789089ef442 (patch) | |
tree | ee4492be8e5b948aa24cd44321157eeb276e2ef2 /gcc/cp | |
parent | 57c304b6f662e6ce28a3ce1413b4726cae936f8a (diff) |
PR c++/52748
* pt.c (tsubst) [DECLTYPE_TYPE]: If ~id is an expression
rather than a destructor name, it isn't an unqualified-name.
(tsubst_copy_and_build): Pass down decltype_flag to operator
handling code, too.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch@197985 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 43 |
2 files changed, 32 insertions, 17 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6398db57ab1..af7fda52754 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2013-04-15 Jason Merrill <jason@redhat.com> + PR c++/52748 + * pt.c (tsubst) [DECLTYPE_TYPE]: If ~id is an expression + rather than a destructor name, it isn't an unqualified-name. + (tsubst_copy_and_build): Pass down decltype_flag to operator + handling code, too. + PR c++/56388 * semantics.c (insert_capture_proxy): Just use index 1 in the stmt_list_stack. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0c7b2ed70e9..5c960e064a8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11800,8 +11800,17 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) else if (DECLTYPE_FOR_LAMBDA_PROXY (t)) type = lambda_proxy_type (type); else - type = finish_decltype_type - (type, DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (t), complain); + { + bool id = DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (t); + if (id && TREE_CODE (DECLTYPE_TYPE_EXPR (t)) == BIT_NOT_EXPR + && EXPR_P (type)) + /* In a template ~id could be either a complement expression + or an unqualified-id naming a destructor; if instantiating + it produces an expression, it's not an id-expression or + member access. */ + id = false; + type = finish_decltype_type (type, id, complain); + } return cp_build_qualified_type_real (type, cp_type_quals (t) | cp_type_quals (type), @@ -13427,9 +13436,8 @@ tsubst_copy_and_build (tree t, /* N3276 decltype magic only applies to calls at the top level or on the right side of a comma. */ - if (TREE_CODE (t) != CALL_EXPR - && TREE_CODE (t) != COMPOUND_EXPR) - complain &= ~tf_decltype; + tsubst_flags_t decltype_flag = (complain & tf_decltype); + complain &= ~tf_decltype; switch (TREE_CODE (t)) { @@ -13517,7 +13525,8 @@ tsubst_copy_and_build (tree t, r = convert_from_reference (r); } else - r = build_x_indirect_ref (input_location, r, RO_UNARY_STAR, complain); + r = build_x_indirect_ref (input_location, r, RO_UNARY_STAR, + complain|decltype_flag); RETURN (r); } @@ -13594,7 +13603,8 @@ tsubst_copy_and_build (tree t, case POSTINCREMENT_EXPR: op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0), args, complain, in_decl); - RETURN (build_x_unary_op (input_location, TREE_CODE (t), op1, complain)); + RETURN (build_x_unary_op (input_location, TREE_CODE (t), op1, + complain|decltype_flag)); case PREDECREMENT_EXPR: case PREINCREMENT_EXPR: @@ -13606,7 +13616,8 @@ tsubst_copy_and_build (tree t, case REALPART_EXPR: case IMAGPART_EXPR: RETURN (build_x_unary_op (input_location, TREE_CODE (t), - RECUR (TREE_OPERAND (t, 0)), complain)); + RECUR (TREE_OPERAND (t, 0)), + complain|decltype_flag)); case FIX_TRUNC_EXPR: RETURN (cp_build_unary_op (FIX_TRUNC_EXPR, RECUR (TREE_OPERAND (t, 0)), @@ -13623,7 +13634,8 @@ tsubst_copy_and_build (tree t, else op1 = tsubst_non_call_postfix_expression (op1, args, complain, in_decl); - RETURN (build_x_unary_op (input_location, ADDR_EXPR, op1, complain)); + RETURN (build_x_unary_op (input_location, ADDR_EXPR, op1, + complain|decltype_flag)); case PLUS_EXPR: case MINUS_EXPR: @@ -13672,7 +13684,7 @@ tsubst_copy_and_build (tree t, ? ERROR_MARK : TREE_CODE (TREE_OPERAND (t, 1))), /*overload=*/NULL, - complain); + complain|decltype_flag); if (EXPR_P (r) && TREE_NO_WARNING (t)) TREE_NO_WARNING (r) = TREE_NO_WARNING (t); @@ -13688,7 +13700,8 @@ tsubst_copy_and_build (tree t, op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0), args, complain, in_decl); RETURN (build_x_array_ref (EXPR_LOCATION (t), op1, - RECUR (TREE_OPERAND (t, 1)), complain)); + RECUR (TREE_OPERAND (t, 1)), + complain|decltype_flag)); case SIZEOF_EXPR: if (PACK_EXPANSION_P (TREE_OPERAND (t, 0))) @@ -13781,7 +13794,7 @@ tsubst_copy_and_build (tree t, RECUR (TREE_OPERAND (t, 0)), TREE_CODE (TREE_OPERAND (t, 1)), RECUR (TREE_OPERAND (t, 2)), - complain); + complain|decltype_flag); /* TREE_NO_WARNING must be set if either the expression was parenthesized or it uses an operator such as >>= rather than plain assignment. In the former case, it was already @@ -13870,7 +13883,7 @@ tsubst_copy_and_build (tree t, RETURN (build_x_compound_expr (EXPR_LOCATION (t), op0, RECUR (TREE_OPERAND (t, 1)), - complain)); + complain|decltype_flag)); } case CALL_EXPR: @@ -13882,10 +13895,6 @@ tsubst_copy_and_build (tree t, bool koenig_p; tree ret; - /* Don't pass tf_decltype down to subexpressions. */ - tsubst_flags_t decltype_flag = (complain & tf_decltype); - complain &= ~tf_decltype; - function = CALL_EXPR_FN (t); /* When we parsed the expression, we determined whether or not Koenig lookup should be performed. */ |