aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/cp/call.c
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2014-07-21 16:47:22 -0700
committerRong Xu <xur@google.com>2014-07-29 15:31:03 -0700
commit38a8aecfb882072900434499696b5c32a2274515 (patch)
tree2aac97f0ae24b03cd98c1a06e989c031c173f889 /gcc-4.9/gcc/cp/call.c
parentc231900e5dcc14d8296bd9f62b45997a49d4d5e7 (diff)
downloadtoolchain_gcc-38a8aecfb882072900434499696b5c32a2274515.tar.gz
toolchain_gcc-38a8aecfb882072900434499696b5c32a2274515.tar.bz2
toolchain_gcc-38a8aecfb882072900434499696b5c32a2274515.zip
[4.9] Switch gcc-4.9 to use google/gcc-4_9 branch.
This source drop uses svn version r212828 of google/gcc-4.9 branch. We also cherry-picked r213062, r213063 and r213064 to fix windows build issues. All gcc-4.9 patches before July 3rd are ported to google/gcc-4.9. The following prior commits has not been merged to google branch yet. (They are included in this commit). e7af147f979e657fe2df00808e5b4319b0e088c6, baf87df3cb2683649ba7e9872362a7e721117c23, and c231900e5dcc14d8296bd9f62b45997a49d4d5e7. Change-Id: I4bea3ea470387ff751c2be4cb0d4a12059b9299b
Diffstat (limited to 'gcc-4.9/gcc/cp/call.c')
-rw-r--r--gcc-4.9/gcc/cp/call.c78
1 files changed, 60 insertions, 18 deletions
diff --git a/gcc-4.9/gcc/cp/call.c b/gcc-4.9/gcc/cp/call.c
index 57e08cb8e..2f24fd49b 100644
--- a/gcc-4.9/gcc/cp/call.c
+++ b/gcc-4.9/gcc/cp/call.c
@@ -206,7 +206,7 @@ static conversion *maybe_handle_ref_bind (conversion **);
static void maybe_handle_implicit_object (conversion **);
static struct z_candidate *add_candidate
(struct z_candidate **, tree, tree, const vec<tree, va_gc> *, size_t,
- conversion **, tree, tree, int, struct rejection_reason *);
+ conversion **, tree, tree, int, struct rejection_reason *, int);
static tree source_type (conversion *);
static void add_warning (struct z_candidate *, struct z_candidate *);
static bool reference_compatible_p (tree, tree);
@@ -520,7 +520,6 @@ struct z_candidate {
sequence from the type returned by FN to the desired destination
type. */
conversion *second_conv;
- int viable;
struct rejection_reason *reason;
/* If FN is a member function, the binfo indicating the path used to
qualify the name of FN at the call site. This path is used to
@@ -538,6 +537,10 @@ struct z_candidate {
tree explicit_targs;
candidate_warning *warnings;
z_candidate *next;
+ int viable;
+
+ /* The flags active in add_candidate. */
+ int flags;
};
/* Returns true iff T is a null pointer constant in the sense of
@@ -886,7 +889,9 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
if (ctor == error_mark_node)
return NULL;
- flags |= LOOKUP_NO_NARROWING;
+ /* The conversions within the init-list aren't affected by the enclosing
+ context; they're always simple copy-initialization. */
+ flags = LOOKUP_IMPLICIT|LOOKUP_NO_NARROWING;
for (; field; field = next_initializable_field (DECL_CHAIN (field)))
{
@@ -959,6 +964,8 @@ build_array_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
return NULL;
}
+ flags = LOOKUP_IMPLICIT|LOOKUP_NO_NARROWING;
+
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), i, val)
{
conversion *sub
@@ -1003,6 +1010,8 @@ build_complex_conv (tree type, tree ctor, int flags,
if (len != 2)
return NULL;
+ flags = LOOKUP_IMPLICIT|LOOKUP_NO_NARROWING;
+
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), i, val)
{
conversion *sub
@@ -1810,7 +1819,8 @@ add_candidate (struct z_candidate **candidates,
tree fn, tree first_arg, const vec<tree, va_gc> *args,
size_t num_convs, conversion **convs,
tree access_path, tree conversion_path,
- int viable, struct rejection_reason *reason)
+ int viable, struct rejection_reason *reason,
+ int flags)
{
struct z_candidate *cand = (struct z_candidate *)
conversion_obstack_alloc (sizeof (struct z_candidate));
@@ -1825,6 +1835,7 @@ add_candidate (struct z_candidate **candidates,
cand->viable = viable;
cand->reason = reason;
cand->next = *candidates;
+ cand->flags = flags;
*candidates = cand;
return cand;
@@ -1994,6 +2005,9 @@ add_function_candidate (struct z_candidate **candidates,
object parameter has reference type. */
bool rv = FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (fn));
parmtype = cp_build_reference_type (parmtype, rv);
+ /* The special handling of 'this' conversions in compare_ics
+ does not apply if there is a ref-qualifier. */
+ is_this = false;
}
else
{
@@ -2061,7 +2075,7 @@ add_function_candidate (struct z_candidate **candidates,
out:
return add_candidate (candidates, fn, orig_first_arg, args, len, convs,
- access_path, conversion_path, viable, reason);
+ access_path, conversion_path, viable, reason, flags);
}
/* Create an overload candidate for the conversion function FN which will
@@ -2163,7 +2177,7 @@ add_conv_candidate (struct z_candidate **candidates, tree fn, tree obj,
}
return add_candidate (candidates, totype, first_arg, arglist, len, convs,
- access_path, conversion_path, viable, reason);
+ access_path, conversion_path, viable, reason, flags);
}
static void
@@ -2238,7 +2252,7 @@ build_builtin_candidate (struct z_candidate **candidates, tree fnname,
num_convs, convs,
/*access_path=*/NULL_TREE,
/*conversion_path=*/NULL_TREE,
- viable, reason);
+ viable, reason, flags);
}
static bool
@@ -3056,7 +3070,7 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
return cand;
fail:
return add_candidate (candidates, tmpl, first_arg, arglist, nargs, NULL,
- access_path, conversion_path, 0, reason);
+ access_path, conversion_path, 0, reason, flags);
}
@@ -4020,8 +4034,9 @@ build_operator_new_call (tree fnname, vec<tree, va_gc> **args,
if (size_check != NULL_TREE)
{
tree errval = TYPE_MAX_VALUE (sizetype);
- /* ANDROID - temporarily disable __cxa_throw_bad_array_new_length call. */
- if (cxx_dialect >= cxx11 && flag_exceptions && 0)
+ if (cxx_dialect >= cxx11 && flag_exceptions
+ /* ANDROID - temporarily disable __cxa_throw_bad_array_new_length call. */
+ && !TARGET_ANDROID)
errval = throw_bad_array_new_length ();
*size = fold_build3 (COND_EXPR, sizetype, size_check,
original_size, errval);
@@ -5743,8 +5758,22 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
usual deallocation function."
So (void*) beats (void*, size_t). */
- if (FUNCTION_ARG_CHAIN (fn) == void_list_node)
- break;
+ /* If type is not void, pick (void*, size_t) version (which comes
+ first). */
+ if (!flag_sized_delete || TREE_CODE (type) == VOID_TYPE )
+ {
+ /* If -fsized-delete is not passed or if a void * is deleted,
+ prefer delete (void *) version. */
+ if (FUNCTION_ARG_CHAIN (fn) == void_list_node)
+ break;
+ }
+ else
+ {
+ /* If -fsized-delete is passed and it is not a void *,
+ prefer delete (void *, size_t) version. */
+ if (FUNCTION_ARG_CHAIN (fn) != void_list_node)
+ break;
+ }
}
}
@@ -6761,7 +6790,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
++nargs;
alcarray = XALLOCAVEC (tree, nargs);
- alcarray[0] = first_arg;
+ alcarray[0] = build_this (first_arg);
FOR_EACH_VEC_SAFE_ELT (args, ix, arg)
alcarray[ix + 1] = arg;
argarray = alcarray;
@@ -7229,7 +7258,11 @@ 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|decltype_flag);
+ tree call = build_cxx_call (fn, nargs, argarray, complain|decltype_flag);
+ if (TREE_CODE (call) == CALL_EXPR
+ && (cand->flags & LOOKUP_LIST_INIT_CTOR))
+ CALL_EXPR_LIST_INIT_P (call) = true;
+ return call;
}
/* Build and return a call to FN, using NARGS arguments in ARGARRAY.
@@ -7271,6 +7304,11 @@ build_cxx_call (tree fn, int nargs, tree *argarray,
|| bif == BUILT_IN_CILKPLUS_SEC_REDUCE
|| bif == BUILT_IN_CILKPLUS_SEC_REDUCE_MUTATING)
{
+ if (call_expr_nargs (fn) == 0)
+ {
+ error_at (EXPR_LOCATION (fn), "Invalid builtin arguments");
+ return error_mark_node;
+ }
/* for bif == BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_ZERO or
BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_ZERO or
BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_NONZERO or
@@ -8456,10 +8494,11 @@ compare_ics (conversion *ics1, conversion *ics2)
/* [over.ics.rank]
--S1 and S2 are reference bindings (_dcl.init.ref_) and neither refers
- to an implicit object parameter, and either S1 binds an lvalue reference
- to an lvalue and S2 binds an rvalue reference or S1 binds an rvalue
- reference to an rvalue and S2 binds an lvalue reference
- (C++0x draft standard, 13.3.3.2)
+ to an implicit object parameter of a non-static member function
+ declared without a ref-qualifier, and either S1 binds an lvalue
+ reference to an lvalue and S2 binds an rvalue reference or S1 binds an
+ rvalue reference to an rvalue and S2 binds an lvalue reference (C++0x
+ draft standard, 13.3.3.2)
--S1 and S2 are reference bindings (_dcl.init.ref_), and the
types to which the references refer are the same type except for
@@ -9232,6 +9271,9 @@ make_temporary_var_for_ref_to_temp (tree decl, tree type)
tree name;
TREE_STATIC (var) = TREE_STATIC (decl);
+ /* Capture the current module info for statics. */
+ if (L_IPO_COMP_MODE && TREE_STATIC (var))
+ varpool_node_for_decl (var);
DECL_TLS_MODEL (var) = DECL_TLS_MODEL (decl);
name = mangle_ref_init_variable (decl);
DECL_NAME (var) = name;