summaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c376
1 files changed, 217 insertions, 159 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 530835b87c8..6817bfc25a0 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -233,7 +233,7 @@ check_dtor_name (tree basetype, tree name)
name = TREE_TYPE (name);
else if (TYPE_P (name))
/* OK */;
- else if (TREE_CODE (name) == IDENTIFIER_NODE)
+ else if (identifier_p (name))
{
if ((MAYBE_CLASS_TYPE_P (basetype)
&& name == constructor_name (basetype))
@@ -554,8 +554,8 @@ null_ptr_cst_p (tree t)
if (CP_INTEGRAL_TYPE_P (TREE_TYPE (t)))
{
/* Core issue 903 says only literal 0 is a null pointer constant. */
- if (cxx_dialect < cxx0x)
- t = maybe_constant_value (t);
+ if (cxx_dialect < cxx11)
+ t = maybe_constant_value (fold_non_dependent_expr_sfinae (t, tf_none));
STRIP_NOPS (t);
if (integer_zerop (t) && !TREE_OVERFLOW (t))
return true;
@@ -1276,7 +1276,10 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
static_fn_type (tofn)))
return NULL;
- from = build_memfn_type (fromfn, tbase, cp_type_quals (tbase));
+ from = build_memfn_type (fromfn,
+ tbase,
+ cp_type_quals (tbase),
+ type_memfn_rqual (tofn));
from = build_ptrmemfunc_type (build_pointer_type (from));
conv = build_conv (ck_pmem, from, conv);
conv->base_p = true;
@@ -1950,7 +1953,19 @@ add_function_candidate (struct z_candidate **candidates,
{
parmtype = cp_build_qualified_type
(ctype, cp_type_quals (TREE_TYPE (parmtype)));
- parmtype = build_pointer_type (parmtype);
+ if (FUNCTION_REF_QUALIFIED (TREE_TYPE (fn)))
+ {
+ /* If the function has a ref-qualifier, the implicit
+ object parameter has reference type. */
+ bool rv = FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (fn));
+ parmtype = cp_build_reference_type (parmtype, rv);
+ }
+ else
+ {
+ parmtype = build_pointer_type (parmtype);
+ arg = build_this (arg);
+ argtype = lvalue_type (arg);
+ }
}
/* Core issue 899: When [copy-]initializing a temporary to be bound
@@ -2285,7 +2300,7 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
T& operator*(T*); */
case INDIRECT_REF:
- if (TREE_CODE (type1) == POINTER_TYPE
+ if (TYPE_PTR_P (type1)
&& !uses_template_parms (TREE_TYPE (type1))
&& (TYPE_PTROB_P (type1)
|| TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE))
@@ -2301,7 +2316,7 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
T operator-(T); */
case UNARY_PLUS_EXPR: /* unary + */
- if (TREE_CODE (type1) == POINTER_TYPE)
+ if (TYPE_PTR_P (type1))
break;
case NEGATE_EXPR:
if (ARITHMETIC_TYPE_P (type1))
@@ -2325,8 +2340,7 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
where CV12 is the union of CV1 and CV2. */
case MEMBER_REF:
- if (TREE_CODE (type1) == POINTER_TYPE
- && TYPE_PTRMEM_P (type2))
+ if (TYPE_PTR_P (type1) && TYPE_PTRMEM_P (type2))
{
tree c1 = TREE_TYPE (type1);
tree c2 = TYPE_PTRMEM_CLASS_TYPE (type2);
@@ -2546,7 +2560,7 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
|| (TYPE_PTR_P (type1) && TYPE_PTR_P (type2))
|| (TYPE_PTRDATAMEM_P (type1) && TYPE_PTRDATAMEM_P (type2))
|| ((TYPE_PTRMEMFUNC_P (type1)
- || TREE_CODE (type1) == POINTER_TYPE)
+ || TYPE_PTR_P (type1))
&& null_ptr_cst_p (args[1])))
{
type2 = type1;
@@ -2905,7 +2919,8 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
fn = fn_type_unification (tmpl, explicit_targs, targs,
args_without_in_chrg,
nargs_without_in_chrg,
- return_type, strict, flags, false);
+ return_type, strict, flags, false,
+ complain & tf_decltype);
if (fn == error_mark_node)
{
@@ -3147,7 +3162,7 @@ print_z_candidate (location_t loc, const char *msgstr,
: ACONCAT ((msgstr, " ", NULL)));
location_t cloc = location_of (candidate->fn);
- if (TREE_CODE (candidate->fn) == IDENTIFIER_NODE)
+ if (identifier_p (candidate->fn))
{
cloc = loc;
if (candidate->num_convs == 3)
@@ -3221,7 +3236,7 @@ print_z_candidate (location_t loc, const char *msgstr,
r->u.template_unification.return_type,
r->u.template_unification.strict,
r->u.template_unification.flags,
- true);
+ true, false);
break;
case rr_invalid_copy:
inform (cloc,
@@ -3447,6 +3462,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags,
int ctorflags = flags;
first_arg = build_int_cst (build_pointer_type (totype), 0);
+ first_arg = build_fold_indirect_ref (first_arg);
/* We should never try to call the abstract or base constructor
from here. */
@@ -3488,7 +3504,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags,
}
if (conv_fns)
- first_arg = build_this (expr);
+ first_arg = expr;
for (; conv_fns; conv_fns = TREE_CHAIN (conv_fns))
{
@@ -3935,8 +3951,13 @@ build_operator_new_call (tree fnname, vec<tree, va_gc> **args,
*fn = NULL_TREE;
/* Set to (size_t)-1 if the size check fails. */
if (size_check != NULL_TREE)
- *size = fold_build3 (COND_EXPR, sizetype, size_check,
- original_size, TYPE_MAX_VALUE (sizetype));
+ {
+ tree errval = TYPE_MAX_VALUE (sizetype);
+ if (cxx_dialect >= cxx11)
+ errval = throw_bad_array_new_length ();
+ *size = fold_build3 (COND_EXPR, sizetype, size_check,
+ original_size, errval);
+ }
vec_safe_insert (*args, 0, *size);
*args = resolve_args (*args, complain);
if (*args == NULL)
@@ -4066,7 +4087,7 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain)
if (fns)
{
- first_mem_arg = build_this (obj);
+ first_mem_arg = obj;
add_candidates (BASELINK_FUNCTIONS (fns),
first_mem_arg, *args, NULL_TREE,
@@ -4082,13 +4103,10 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain)
tree fns = TREE_VALUE (convs);
tree totype = TREE_TYPE (convs);
- if ((TREE_CODE (totype) == POINTER_TYPE
- && TREE_CODE (TREE_TYPE (totype)) == FUNCTION_TYPE)
+ if (TYPE_PTRFN_P (totype)
+ || TYPE_REFFN_P (totype)
|| (TREE_CODE (totype) == REFERENCE_TYPE
- && TREE_CODE (TREE_TYPE (totype)) == FUNCTION_TYPE)
- || (TREE_CODE (totype) == REFERENCE_TYPE
- && TREE_CODE (TREE_TYPE (totype)) == POINTER_TYPE
- && TREE_CODE (TREE_TYPE (TREE_TYPE (totype))) == FUNCTION_TYPE))
+ && TYPE_PTRFN_P (TREE_TYPE (totype))))
for (; fns; fns = OVL_NEXT (fns))
{
tree fn = OVL_CURRENT (fns);
@@ -4335,7 +4353,7 @@ conditional_conversion (tree e1, tree e2, tsubst_flags_t complain)
arguments to the conditional expression. */
static tree
-build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
+build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3,
tsubst_flags_t complain)
{
tree arg2_type;
@@ -4355,7 +4373,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
if (!arg2)
{
if (complain & tf_error)
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (loc, OPT_Wpedantic,
"ISO C++ forbids omitting the middle term of a ?: expression");
/* Make sure that lvalues remain lvalues. See g++.oliva/ext1.C. */
@@ -4389,8 +4407,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
&& TREE_CODE (arg3_type) != VECTOR_TYPE)
{
if (complain & tf_error)
- error ("at least one operand of a vector conditional operator "
- "must be a vector");
+ error_at (loc, "at least one operand of a vector conditional "
+ "operator must be a vector");
return error_mark_node;
}
@@ -4398,7 +4416,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
!= (TREE_CODE (arg3_type) == VECTOR_TYPE))
{
enum stv_conv convert_flag =
- scalar_to_vector (input_location, VEC_COND_EXPR, arg2, arg3,
+ scalar_to_vector (loc, VEC_COND_EXPR, arg2, arg3,
complain & tf_error);
switch (convert_flag)
@@ -4430,16 +4448,17 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
|| TYPE_SIZE (arg1_type) != TYPE_SIZE (arg2_type))
{
if (complain & tf_error)
- error ("incompatible vector types in conditional expression: "
- "%qT, %qT and %qT", TREE_TYPE (arg1), TREE_TYPE (orig_arg2),
- TREE_TYPE (orig_arg3));
+ error_at (loc,
+ "incompatible vector types in conditional expression: "
+ "%qT, %qT and %qT", TREE_TYPE (arg1),
+ TREE_TYPE (orig_arg2), TREE_TYPE (orig_arg3));
return error_mark_node;
}
if (!COMPARISON_CLASS_P (arg1))
- arg1 = build2 (NE_EXPR, signed_type_for (arg1_type), arg1,
- build_zero_cst (arg1_type));
- return build3 (VEC_COND_EXPR, arg2_type, arg1, arg2, arg3);
+ arg1 = cp_build_binary_op (loc, NE_EXPR, arg1,
+ build_zero_cst (arg1_type), complain);
+ return fold_build3 (VEC_COND_EXPR, arg2_type, arg1, arg2, arg3);
}
/* [expr.cond]
@@ -4517,15 +4536,15 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
if (complain & tf_error)
{
if (VOID_TYPE_P (arg2_type))
- error ("second operand to the conditional operator "
- "is of type %<void%>, "
- "but the third operand is neither a throw-expression "
- "nor of type %<void%>");
+ error_at (EXPR_LOC_OR_LOC (arg3, loc),
+ "second operand to the conditional operator "
+ "is of type %<void%>, but the third operand is "
+ "neither a throw-expression nor of type %<void%>");
else
- error ("third operand to the conditional operator "
- "is of type %<void%>, "
- "but the second operand is neither a throw-expression "
- "nor of type %<void%>");
+ error_at (EXPR_LOC_OR_LOC (arg2, loc),
+ "third operand to the conditional operator "
+ "is of type %<void%>, but the second operand is "
+ "neither a throw-expression nor of type %<void%>");
}
return error_mark_node;
}
@@ -4564,8 +4583,9 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
|| (conv2 && conv2->kind == ck_ambig)
|| (conv3 && conv3->kind == ck_ambig))
{
- error ("operands to ?: have different types %qT and %qT",
- arg2_type, arg3_type);
+ if (complain & tf_error)
+ error_at (loc, "operands to ?: have different types %qT and %qT",
+ arg2_type, arg3_type);
result = error_mark_node;
}
else if (conv2 && (!conv2->bad_p || !conv3))
@@ -4671,9 +4691,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
{
if (complain & tf_error)
{
- op_error (input_location, COND_EXPR, NOP_EXPR,
- arg1, arg2, arg3, FALSE);
- print_z_candidates (location_of (arg1), candidates);
+ op_error (loc, COND_EXPR, NOP_EXPR, arg1, arg2, arg3, FALSE);
+ print_z_candidates (loc, candidates);
}
return error_mark_node;
}
@@ -4682,9 +4701,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
{
if (complain & tf_error)
{
- op_error (input_location, COND_EXPR, NOP_EXPR,
- arg1, arg2, arg3, FALSE);
- print_z_candidates (location_of (arg1), candidates);
+ op_error (loc, COND_EXPR, NOP_EXPR, arg1, arg2, arg3, FALSE);
+ print_z_candidates (loc, candidates);
}
return error_mark_node;
}
@@ -4747,10 +4765,11 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
/* In this case, there is always a common type. */
result_type = type_after_usual_arithmetic_conversions (arg2_type,
arg3_type);
- do_warn_double_promotion (result_type, arg2_type, arg3_type,
- "implicit conversion from %qT to %qT to "
- "match other result of conditional",
- input_location);
+ if (complain & tf_warning)
+ do_warn_double_promotion (result_type, arg2_type, arg3_type,
+ "implicit conversion from %qT to %qT to "
+ "match other result of conditional",
+ loc);
if (TREE_CODE (arg2_type) == ENUMERAL_TYPE
&& TREE_CODE (arg3_type) == ENUMERAL_TYPE)
@@ -4761,19 +4780,20 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
/* Two enumerators from the same enumeration can have different
types when the enumeration is still being defined. */;
else if (complain & tf_warning)
- warning (OPT_Wenum_compare,
- "enumeral mismatch in conditional expression: %qT vs %qT",
- arg2_type, arg3_type);
+ warning_at (loc, OPT_Wenum_compare, "enumeral mismatch in "
+ "conditional expression: %qT vs %qT",
+ arg2_type, arg3_type);
}
else if (extra_warnings
&& ((TREE_CODE (arg2_type) == ENUMERAL_TYPE
&& !same_type_p (arg3_type, type_promotes_to (arg2_type)))
|| (TREE_CODE (arg3_type) == ENUMERAL_TYPE
- && !same_type_p (arg2_type, type_promotes_to (arg3_type)))))
+ && !same_type_p (arg2_type,
+ type_promotes_to (arg3_type)))))
{
if (complain & tf_warning)
- warning (0,
- "enumeral and non-enumeral type in conditional expression");
+ warning_at (loc, 0, "enumeral and non-enumeral type in "
+ "conditional expression");
}
arg2 = perform_implicit_conversion (result_type, arg2, complain);
@@ -4815,8 +4835,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
if (!result_type)
{
if (complain & tf_error)
- error ("operands to ?: have different types %qT and %qT",
- arg2_type, arg3_type);
+ error_at (loc, "operands to ?: have different types %qT and %qT",
+ arg2_type, arg3_type);
return error_mark_node;
}
@@ -4844,6 +4864,8 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
lvalue, we must add a NON_LVALUE_EXPR. */
result = rvalue (result);
}
+ else
+ result = force_paren_expr (result);
return result;
}
@@ -4851,12 +4873,12 @@ build_conditional_expr_1 (tree arg1, tree arg2, tree arg3,
/* Wrapper for above. */
tree
-build_conditional_expr (tree arg1, tree arg2, tree arg3,
+build_conditional_expr (location_t loc, tree arg1, tree arg2, tree arg3,
tsubst_flags_t complain)
{
tree ret;
bool subtime = timevar_cond_start (TV_OVERLOAD);
- ret = build_conditional_expr_1 (arg1, arg2, arg3, complain);
+ ret = build_conditional_expr_1 (loc, arg1, arg2, arg3, complain);
timevar_cond_stop (TV_OVERLOAD, subtime);
return ret;
}
@@ -4924,7 +4946,7 @@ add_candidates (tree fns, tree first_arg, const vec<tree, va_gc> *args,
is considered to be a member of the class of the implicit
object argument for the purpose of defining the type of
the implicit object parameter. */
- ctype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (first_arg)));
+ ctype = TYPE_MAIN_VARIANT (TREE_TYPE (first_arg));
}
else
{
@@ -4978,7 +5000,7 @@ add_candidates (tree fns, tree first_arg, const vec<tree, va_gc> *args,
for (ix = 1; args->iterate (ix, &arg); ++ix)
tempvec->quick_push (arg);
non_static_args = tempvec;
- first_arg = build_this ((*args)[0]);
+ first_arg = (*args)[0];
}
fn_first_arg = first_arg;
@@ -5082,8 +5104,8 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1,
if (code == COND_EXPR)
/* Use build_conditional_expr instead. */
gcc_unreachable ();
- else if (! IS_OVERLOAD_TYPE (TREE_TYPE (arg1))
- && (! arg2 || ! IS_OVERLOAD_TYPE (TREE_TYPE (arg2))))
+ else if (! OVERLOAD_TYPE_P (TREE_TYPE (arg1))
+ && (! arg2 || ! OVERLOAD_TYPE_P (TREE_TYPE (arg2))))
goto builtin;
if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR)
@@ -5396,7 +5418,7 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1,
case BIT_AND_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
- return cp_build_binary_op (input_location, code, arg1, arg2, complain);
+ return cp_build_binary_op (loc, code, arg1, arg2, complain);
case UNARY_PLUS_EXPR:
case NEGATE_EXPR:
@@ -5709,12 +5731,12 @@ build_temp (tree expr, tree type, int flags,
int savew, savee;
vec<tree, va_gc> *args;
- savew = warningcount, savee = errorcount;
+ savew = warningcount + werrorcount, savee = errorcount;
args = make_tree_vector_single (expr);
expr = build_special_member_call (NULL_TREE, complete_ctor_identifier,
&args, type, flags, complain);
release_tree_vector (args);
- if (warningcount > savew)
+ if (warningcount + werrorcount > savew)
*diagnostic_kind = DK_WARNING;
else if (errorcount > savee)
*diagnostic_kind = DK_ERROR;
@@ -5836,11 +5858,17 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
break;
}
- permerror (loc, "invalid conversion from %qT to %qT",
- TREE_TYPE (expr), totype);
- if (fn)
- permerror (DECL_SOURCE_LOCATION (fn),
- " initializing argument %P of %qD", argnum, fn);
+ if (flag_enable_cilkplus
+ && (contains_array_notation_expr (expr)
+ || contains_array_notation_expr (fn)))
+ /* If we are using array notations, we fix them up at a later stage
+ and we will do these checks then. */
+ ;
+ else if (permerror (loc, "invalid conversion from %qT to %qT",
+ TREE_TYPE (expr), totype)
+ && fn)
+ inform (DECL_SOURCE_LOCATION (fn),
+ "initializing argument %P of %qD", argnum, fn);
return cp_convert (totype, expr, complain);
}
@@ -5856,6 +5884,17 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
tree convfn = cand->fn;
unsigned i;
+ /* When converting from an init list we consider explicit
+ constructors, but actually trying to call one is an error. */
+ if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn)
+ /* Unless this is for direct-list-initialization. */
+ && !(BRACE_ENCLOSED_INITIALIZER_P (expr)
+ && CONSTRUCTOR_IS_DIRECT_INIT (expr)))
+ {
+ error ("converting to %qT from initializer list would use "
+ "explicit constructor %qD", totype, convfn);
+ }
+
/* If we're initializing from {}, it's value-initialization. */
if (BRACE_ENCLOSED_INITIALIZER_P (expr)
&& CONSTRUCTOR_NELTS (expr) == 0
@@ -5874,20 +5913,6 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
expr = mark_rvalue_use (expr);
- /* When converting from an init list we consider explicit
- constructors, but actually trying to call one is an error. */
- if (DECL_NONCONVERTING_P (convfn) && DECL_CONSTRUCTOR_P (convfn)
- /* Unless this is for direct-list-initialization. */
- && !(BRACE_ENCLOSED_INITIALIZER_P (expr)
- && CONSTRUCTOR_IS_DIRECT_INIT (expr))
- /* Unless we're calling it for value-initialization from an
- empty list, since that is handled separately in 8.5.4. */
- && cand->num_convs > 0)
- {
- error ("converting to %qT from initializer list would use "
- "explicit constructor %qD", totype, convfn);
- }
-
/* Set user_conv_p on the argument conversions, so rvalue/base
handling knows not to allow any more UDCs. */
for (i = 0; i < cand->num_convs; ++i)
@@ -5946,7 +5971,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
build_user_type_conversion (totype, convs->u.expr, LOOKUP_NORMAL,
complain);
if (fn)
- error (" initializing argument %P of %q+D", argnum, fn);
+ inform (input_location, "initializing argument %P of %q+D",
+ argnum, fn);
}
return error_mark_node;
@@ -6077,7 +6103,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
error_at (loc, "cannot bind %qT lvalue to %qT",
TREE_TYPE (expr), totype);
if (fn)
- error (" initializing argument %P of %q+D", argnum, fn);
+ inform (input_location,
+ "initializing argument %P of %q+D", argnum, fn);
return error_mark_node;
}
@@ -6178,10 +6205,10 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
if (convs->check_narrowing)
check_narrowing (totype, expr);
- if (issue_conversion_warnings && (complain & tf_warning))
- expr = convert_and_check (totype, expr);
+ if (issue_conversion_warnings)
+ expr = cp_convert_and_check (totype, expr, complain);
else
- expr = convert (totype, expr);
+ expr = cp_convert (totype, expr, complain);
return expr;
}
@@ -6696,6 +6723,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);
@@ -6707,16 +6738,18 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
resolution, and must be of the proper type. */
if (DECL_CONSTRUCTOR_P (fn))
{
+ tree object_arg;
if (first_arg != NULL_TREE)
{
- argarray[j++] = first_arg;
+ object_arg = first_arg;
first_arg = NULL_TREE;
}
else
{
- argarray[j++] = (*args)[arg_index];
+ object_arg = (*args)[arg_index];
++arg_index;
}
+ argarray[j++] = build_this (object_arg);
parm = TREE_CHAIN (parm);
/* We should never try to call the abstract constructor. */
gcc_assert (!DECL_HAS_IN_CHARGE_PARM_P (fn));
@@ -6732,9 +6765,9 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
else if (TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE)
{
tree parmtype = TREE_VALUE (parm);
- tree arg = (first_arg != NULL_TREE
- ? first_arg
- : (*args)[arg_index]);
+ tree arg = build_this (first_arg != NULL_TREE
+ ? first_arg
+ : (*args)[arg_index]);
tree argtype = TREE_TYPE (arg);
tree converted_arg;
tree base_binfo;
@@ -6760,7 +6793,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
So we can assume that anything passed as 'this' is non-null, and
optimize accordingly. */
- gcc_assert (TREE_CODE (parmtype) == POINTER_TYPE);
+ gcc_assert (TYPE_PTR_P (parmtype));
/* Convert to the base in which the function was declared. */
gcc_assert (cand->conversion_path != NULL_TREE);
converted_arg = build_base_path (PLUS_EXPR,
@@ -6770,9 +6803,14 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
/* Check that the base class is accessible. */
if (!accessible_base_p (TREE_TYPE (argtype),
BINFO_TYPE (cand->conversion_path), true))
- error ("%qT is not an accessible base of %qT",
- BINFO_TYPE (cand->conversion_path),
- TREE_TYPE (argtype));
+ {
+ if (complain & tf_error)
+ error ("%qT is not an accessible base of %qT",
+ BINFO_TYPE (cand->conversion_path),
+ TREE_TYPE (argtype));
+ else
+ return error_mark_node;
+ }
/* If fn was found by a using declaration, the conversion path
will be to the derived class, not the base declaring fn. We
must convert from derived to base. */
@@ -6858,12 +6896,20 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
}
}
- val = convert_like_with_context (conv, arg, fn, i-is_method,
- conversion_warning
- ? complain
- : complain & (~tf_warning));
+ /* If the function call is builtin array notation function then no need
+ to do any type conversion. */
+ if (flag_enable_cilkplus
+ && is_cilkplus_reduce_builtin (fn) != BUILT_IN_NONE)
+ val = arg;
+ else
+ {
+ val = convert_like_with_context (conv, arg, fn, i - is_method,
+ conversion_warning
+ ? complain
+ : complain & (~tf_warning));
- val = convert_for_arg_passing (type, val, complain);
+ val = convert_for_arg_passing (type, val, complain);
+ }
if (val == error_mark_node)
return error_mark_node;
else
@@ -7021,7 +7067,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
otherwise the call should go through the dispatcher. */
if (DECL_FUNCTION_VERSIONED (fn)
- && !targetm.target_option.can_inline_p (current_function_decl, fn))
+ && (current_function_decl == NULL
+ || !targetm.target_option.can_inline_p (current_function_decl, fn)))
{
fn = get_function_version_dispatcher (fn);
if (fn == NULL)
@@ -7067,7 +7114,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.
@@ -7109,12 +7156,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);
}
@@ -7150,7 +7205,7 @@ build_java_interface_fn_ref (tree fn, tree instance)
/* Get the java.lang.Class pointer for the interface being called. */
iface = DECL_CONTEXT (fn);
iface_ref = lookup_field (iface, get_identifier ("class$"), 0, false);
- if (!iface_ref || TREE_CODE (iface_ref) != VAR_DECL
+ if (!iface_ref || !VAR_P (iface_ref)
|| DECL_CONTEXT (iface_ref) != iface)
{
error ("could not find class$ field in java interface type %qT",
@@ -7388,7 +7443,6 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
tree access_binfo;
tree optype;
tree first_mem_arg = NULL_TREE;
- tree instance_ptr;
tree name;
bool skip_first_for_error;
vec<tree, va_gc> *user_args;
@@ -7458,11 +7512,11 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
if (! (complain & tf_error))
return error_mark_node;
- permerror (input_location,
- "cannot call constructor %<%T::%D%> directly",
- basetype, name);
- permerror (input_location, " for a function-style cast, remove the "
- "redundant %<::%D%>", name);
+ if (permerror (input_location,
+ "cannot call constructor %<%T::%D%> directly",
+ basetype, name))
+ inform (input_location, "for a function-style cast, remove the "
+ "redundant %<::%D%>", name);
call = build_functional_cast (basetype, build_tree_list_vec (user_args),
complain);
return call;
@@ -7496,22 +7550,27 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
return error_mark_node;
}
- instance_ptr = build_this (instance);
+ /* Consider the object argument to be used even if we end up selecting a
+ static member function. */
+ instance = mark_type_use (instance);
/* It's OK to call destructors and constructors on cv-qualified objects.
- Therefore, convert the INSTANCE_PTR to the unqualified type, if
+ Therefore, convert the INSTANCE to the unqualified type, if
necessary. */
if (DECL_DESTRUCTOR_P (fn)
|| DECL_CONSTRUCTOR_P (fn))
{
- tree type = build_pointer_type (basetype);
- if (!same_type_p (type, TREE_TYPE (instance_ptr)))
- instance_ptr = build_nop (type, instance_ptr);
+ if (!same_type_p (basetype, TREE_TYPE (instance)))
+ {
+ instance = build_this (instance);
+ instance = build_nop (build_pointer_type (basetype), instance);
+ instance = build_fold_indirect_ref (instance);
+ }
}
if (DECL_DESTRUCTOR_P (fn))
name = complete_dtor_identifier;
- first_mem_arg = instance_ptr;
+ first_mem_arg = instance;
/* Get the high-water mark for the CONVERSION_OBSTACK. */
p = conversion_obstack_alloc (0);
@@ -7547,11 +7606,10 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
if (init)
{
- tree ob;
- if (integer_zerop (instance_ptr))
+ if (TREE_CODE (instance) == INDIRECT_REF
+ && integer_zerop (TREE_OPERAND (instance, 0)))
return get_target_expr_sfinae (init, complain);
- ob = build_fold_indirect_ref (instance_ptr);
- init = build2 (INIT_EXPR, TREE_TYPE (ob), ob, init);
+ init = build2 (INIT_EXPR, TREE_TYPE (instance), instance, init);
TREE_SIDE_EFFECTS (init) = true;
return init;
}
@@ -7576,11 +7634,11 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
if (complain & tf_error)
{
if (!COMPLETE_OR_OPEN_TYPE_P (basetype))
- cxx_incomplete_type_error (instance_ptr, basetype);
+ cxx_incomplete_type_error (instance, basetype);
else if (optype)
error ("no matching function for call to %<%T::operator %T(%A)%#V%>",
basetype, optype, build_tree_list_vec (user_args),
- TREE_TYPE (TREE_TYPE (instance_ptr)));
+ TREE_TYPE (instance));
else
{
char *pretty_name;
@@ -7593,7 +7651,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
arglist = TREE_CHAIN (arglist);
error ("no matching function for call to %<%T::%s(%A)%#V%>",
basetype, pretty_name, arglist,
- TREE_TYPE (TREE_TYPE (instance_ptr)));
+ TREE_TYPE (instance));
if (free_p)
free (pretty_name);
}
@@ -7643,7 +7701,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
fn);
if (TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE
- && is_dummy_object (instance_ptr))
+ && is_dummy_object (instance))
{
instance = maybe_resolve_dummy (instance);
if (instance == error_mark_node)
@@ -7652,8 +7710,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
{
/* We captured 'this' in the current lambda now that
we know we really need it. */
- instance_ptr = build_this (instance);
- cand->first_arg = instance_ptr;
+ cand->first_arg = instance;
}
else
{
@@ -7688,10 +7745,10 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
out to be a static member function, `a' is
none-the-less evaluated. */
if (TREE_CODE (TREE_TYPE (fn)) != METHOD_TYPE
- && !is_dummy_object (instance_ptr)
- && TREE_SIDE_EFFECTS (instance_ptr))
+ && !is_dummy_object (instance)
+ && TREE_SIDE_EFFECTS (instance))
call = build2 (COMPOUND_EXPR, TREE_TYPE (call),
- instance_ptr, call);
+ instance, call);
else if (call != error_mark_node
&& DECL_DESTRUCTOR_P (cand->fn)
&& !VOID_TYPE_P (TREE_TYPE (call)))
@@ -7721,7 +7778,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
cast_to_void = true;
call = TREE_OPERAND (call, 0);
}
- if (TREE_CODE (call) == INDIRECT_REF)
+ if (INDIRECT_REF_P (call))
call = TREE_OPERAND (call, 0);
call = (build_min_non_dep_call_vec
(call,
@@ -8122,8 +8179,8 @@ compare_ics (conversion *ics1, conversion *ics2)
conversion of B* to A* is better than conversion of B* to
void*, and conversion of A* to void* is better than
conversion of B* to void*. */
- if (TREE_CODE (deref_to_type1) == VOID_TYPE
- && TREE_CODE (deref_to_type2) == VOID_TYPE)
+ if (VOID_TYPE_P (deref_to_type1)
+ && VOID_TYPE_P (deref_to_type2))
{
if (is_properly_derived_from (deref_from_type1,
deref_from_type2))
@@ -8132,12 +8189,12 @@ compare_ics (conversion *ics1, conversion *ics2)
deref_from_type1))
return 1;
}
- else if (TREE_CODE (deref_to_type1) == VOID_TYPE
- || TREE_CODE (deref_to_type2) == VOID_TYPE)
+ else if (VOID_TYPE_P (deref_to_type1)
+ || VOID_TYPE_P (deref_to_type2))
{
if (same_type_p (deref_from_type1, deref_from_type2))
{
- if (TREE_CODE (deref_to_type2) == VOID_TYPE)
+ if (VOID_TYPE_P (deref_to_type2))
{
if (is_properly_derived_from (deref_from_type1,
deref_to_type1))
@@ -8554,8 +8611,7 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn,
- do not have the same parameter type list as any non-template
non-member candidate. */
- if (TREE_CODE (cand1->fn) == IDENTIFIER_NODE
- || TREE_CODE (cand2->fn) == IDENTIFIER_NODE)
+ if (identifier_p (cand1->fn) || identifier_p (cand2->fn))
{
for (i = 0; i < len; ++i)
if (!same_type_p (cand1->convs[i]->type,
@@ -8566,7 +8622,7 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn,
if (cand1->fn == cand2->fn)
/* Two built-in candidates; arbitrarily pick one. */
return 1;
- else if (TREE_CODE (cand1->fn) == IDENTIFIER_NODE)
+ else if (identifier_p (cand1->fn))
/* cand1 is built-in; prefer cand2. */
return -1;
else
@@ -8642,13 +8698,15 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn,
{
if (complain & tf_error)
{
- permerror (input_location,
- "default argument mismatch in "
- "overload resolution");
- inform (input_location,
- " candidate 1: %q+#F", cand1->fn);
- inform (input_location,
- " candidate 2: %q+#F", cand2->fn);
+ if (permerror (input_location,
+ "default argument mismatch in "
+ "overload resolution"))
+ {
+ inform (input_location,
+ " candidate 1: %q+#F", cand1->fn);
+ inform (input_location,
+ " candidate 2: %q+#F", cand2->fn);
+ }
}
else
return 0;
@@ -8996,7 +9054,7 @@ make_temporary_var_for_ref_to_temp (tree decl, tree type)
var = create_temporary_var (type);
/* Register the variable. */
- if (TREE_CODE (decl) == VAR_DECL
+ if (VAR_P (decl)
&& (TREE_STATIC (decl) || DECL_THREAD_LOCAL_P (decl)))
{
/* Namespace-scope or local static; give it a mangled name. */