aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-03-16 22:37:09 -0400
committerJason Merrill <jason@gcc.gnu.org>2013-03-16 22:37:09 -0400
commit57fcd4f4e4f12b1ede24f05385183d3f2dc7acfa (patch)
treec09183570e99438a8ee808eb03a342623d63c77f /gcc/cp/call.c
parent2df663ccedf750ffe5ac481b3fe2aaff0d985a7f (diff)
downloadgcc-57fcd4f4e4f12b1ede24f05385183d3f2dc7acfa.zip
gcc-57fcd4f4e4f12b1ede24f05385183d3f2dc7acfa.tar.gz
gcc-57fcd4f4e4f12b1ede24f05385183d3f2dc7acfa.tar.bz2
re PR c++/52748 ([C++11] N3276 changes to decltype)
N3276 PR c++/52748 * cp-tree.h (tsubst_flags): Add tf_decltype. * call.c (build_cxx_call): Don't build a temporary if it's set. (build_over_call): Make sure it's only passed to build_cxx_call. * parser.c (cp_parser_primary_expression): Add decltype_p parm. (cp_parser_unary_expression): Likewise. (cp_parser_cast_expression): Likewise. (cp_parser_binary_expression): Likewise. (cp_parser_assignment_expression): Likewise. (cp_parser_postfix_expression): Likewise. Pass tf_decltype. (cp_parser_explicit_instantiation): Add decltype_p. Force a temporary for a call on the LHS of a comma. (cp_parser_decltype): Pass true to decltype_p parms. * pt.c (tsubst) [DECLTYPE_TYPE]: Pass tf_decltype. (tsubst_copy_and_build): Pass tf_decltype down only for CALL_EXPR and the RHS of COMPOUND_EXPR. * tree.c (build_cplus_new): Call complete_type_or_maybe_complain. From-SVN: r196736
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index e40c45f..8362c75 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6693,6 +6693,10 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
/* else continue to get conversion error. */
}
+ /* N3276 magic doesn't apply to nested calls. */
+ int decltype_flag = (complain & tf_decltype);
+ complain &= ~tf_decltype;
+
/* Find maximum size of vector to hold converted arguments. */
parmlen = list_length (parm);
nargs = vec_safe_length (args) + (first_arg != NULL_TREE ? 1 : 0);
@@ -7064,7 +7068,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
return error_mark_node;
}
- return build_cxx_call (fn, nargs, argarray, complain);
+ return build_cxx_call (fn, nargs, argarray, complain|decltype_flag);
}
/* Build and return a call to FN, using NARGS arguments in ARGARRAY.
@@ -7106,12 +7110,20 @@ build_cxx_call (tree fn, int nargs, tree *argarray,
if (VOID_TYPE_P (TREE_TYPE (fn)))
return fn;
- fn = require_complete_type_sfinae (fn, complain);
- if (fn == error_mark_node)
- return error_mark_node;
+ /* 5.2.2/11: If a function call is a prvalue of object type: if the
+ function call is either the operand of a decltype-specifier or the
+ right operand of a comma operator that is the operand of a
+ decltype-specifier, a temporary object is not introduced for the
+ prvalue. The type of the prvalue may be incomplete. */
+ if (!(complain & tf_decltype))
+ {
+ fn = require_complete_type_sfinae (fn, complain);
+ if (fn == error_mark_node)
+ return error_mark_node;
- if (MAYBE_CLASS_TYPE_P (TREE_TYPE (fn)))
- fn = build_cplus_new (TREE_TYPE (fn), fn, complain);
+ if (MAYBE_CLASS_TYPE_P (TREE_TYPE (fn)))
+ fn = build_cplus_new (TREE_TYPE (fn), fn, complain);
+ }
return convert_from_reference (fn);
}