summaryrefslogtreecommitdiffstats
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-16 22:29:52 +0000
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-16 22:29:52 +0000
commit389dd41bd043170e7dc7660304f14a5f16af3562 (patch)
treee4de0ffc0a0ca77f35b03bf9e8a248a4b5735f6a /gcc/builtins.c
parentc1c67b4f5041c4367842002c81ffe912ff97f2d8 (diff)
downloadppe42-gcc-389dd41bd043170e7dc7660304f14a5f16af3562.tar.gz
ppe42-gcc-389dd41bd043170e7dc7660304f14a5f16af3562.zip
2009-07-17 Aldy Hernandez <aldyh@redhat.com>
Manuel López-Ibáñez <manu@gcc.gnu.org> PR 40435 * tree-complex.c, tree-loop-distribution.c, tree.c, tree.h, builtins.c, fold-const.c, omp-low.c, cgraphunit.c, tree-ssa-ccp.c, tree-ssa-dom.c, gimple-low.c, expr.c, tree-ssa-ifcombine.c, c-decl.c, stor-layout.c, tree-if-conv.c, c-typeck.c, gimplify.c, calls.c, tree-sra.c, tree-mudflap.c, tree-ssa-copy.c, tree-ssa-forwprop.c, c-convert.c, c-omp.c, varasm.c, tree-inline.c, c-common.c, c-common.h, gimple.c, tree-switch-conversion.c, gimple.h, tree-cfg.c, c-parser.c, convert.c: Add location argument to fold_{unary,binary,ternary}, fold_build[123], build_call_expr, build_size_arg, build_fold_addr_expr, build_call_array, non_lvalue, size_diffop, fold_build1_initializer, fold_build2_initializer, fold_build3_initializer, fold_build_call_array, fold_build_call_array_initializer, fold_single_bit_test, omit_one_operand, omit_two_operands, invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, combine_comparisons, fold_builtin_*, fold_call_expr, build_range_check, maybe_fold_offset_to_address, round_up, round_down. objc/ * objc-act.c: Add location argument to all calls to build_fold_addr_expr. testsuite/ * gcc.dg/pr36902.c: Add column info. * g++.dg/gcov/gcov-2.C: Change count for definition. cp/ * typeck.c, init.c, class.c, method.c, rtti.c, except.c, error.c, tree.c, cp-gimplify.c, cxx-pretty-print.c, pt.c, semantics.c, call.c, cvt.c, mangle.c: Add location argument to fold_{unary,binary,ternary}, fold_build[123], build_call_expr, build_size_arg, build_fold_addr_expr, build_call_array, non_lvalue, size_diffop, fold_build1_initializer, fold_build2_initializer, fold_build3_initializer, fold_build_call_array, fold_build_call_array_initializer, fold_single_bit_test, omit_one_operand, omit_two_operands, invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, combine_comparisons, fold_builtin_*, fold_call_expr, build_range_check, maybe_fold_offset_to_address, round_up, round_down. fortran/ * trans-expr.c, trans-array.c, trans-openmp.c, trans-stmt.c, trans.c, trans-io.c, trans-decl.c, trans-intrinsic.c: Add location argument to fold_{unary,binary,ternary}, fold_build[123], build_call_expr, build_size_arg, build_fold_addr_expr, build_call_array, non_lvalue, size_diffop, fold_build1_initializer, fold_build2_initializer, fold_build3_initializer, fold_build_call_array, fold_build_call_array_initializer, fold_single_bit_test, omit_one_operand, omit_two_operands, invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, combine_comparisons, fold_builtin_*, fold_call_expr, build_range_check, maybe_fold_offset_to_address, round_up, round_down. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149722 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c1293
1 files changed, 693 insertions, 600 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index a94a37901a7..5a474cd0eaa 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -152,65 +152,65 @@ static rtx expand_builtin_fputs (tree, rtx, bool);
static rtx expand_builtin_printf (tree, rtx, enum machine_mode, bool);
static rtx expand_builtin_fprintf (tree, rtx, enum machine_mode, bool);
static rtx expand_builtin_sprintf (tree, rtx, enum machine_mode);
-static tree stabilize_va_list (tree, int);
+static tree stabilize_va_list_loc (location_t, tree, int);
static rtx expand_builtin_expect (tree, rtx);
static tree fold_builtin_constant_p (tree);
-static tree fold_builtin_expect (tree, tree);
+static tree fold_builtin_expect (location_t, tree, tree);
static tree fold_builtin_classify_type (tree);
-static tree fold_builtin_strlen (tree);
-static tree fold_builtin_inf (tree, int);
+static tree fold_builtin_strlen (location_t, tree);
+static tree fold_builtin_inf (location_t, tree, int);
static tree fold_builtin_nan (tree, tree, int);
-static tree rewrite_call_expr (tree, int, tree, int, ...);
+static tree rewrite_call_expr (location_t, tree, int, tree, int, ...);
static bool validate_arg (const_tree, enum tree_code code);
static bool integer_valued_real_p (tree);
-static tree fold_trunc_transparent_mathfn (tree, tree);
+static tree fold_trunc_transparent_mathfn (location_t, tree, tree);
static bool readonly_data_expr (tree);
static rtx expand_builtin_fabs (tree, rtx, rtx);
static rtx expand_builtin_signbit (tree, rtx);
-static tree fold_builtin_sqrt (tree, tree);
-static tree fold_builtin_cbrt (tree, tree);
-static tree fold_builtin_pow (tree, tree, tree, tree);
-static tree fold_builtin_powi (tree, tree, tree, tree);
-static tree fold_builtin_cos (tree, tree, tree);
-static tree fold_builtin_cosh (tree, tree, tree);
+static tree fold_builtin_sqrt (location_t, tree, tree);
+static tree fold_builtin_cbrt (location_t, tree, tree);
+static tree fold_builtin_pow (location_t, tree, tree, tree, tree);
+static tree fold_builtin_powi (location_t, tree, tree, tree, tree);
+static tree fold_builtin_cos (location_t, tree, tree, tree);
+static tree fold_builtin_cosh (location_t, tree, tree, tree);
static tree fold_builtin_tan (tree, tree);
-static tree fold_builtin_trunc (tree, tree);
-static tree fold_builtin_floor (tree, tree);
-static tree fold_builtin_ceil (tree, tree);
-static tree fold_builtin_round (tree, tree);
-static tree fold_builtin_int_roundingfn (tree, tree);
+static tree fold_builtin_trunc (location_t, tree, tree);
+static tree fold_builtin_floor (location_t, tree, tree);
+static tree fold_builtin_ceil (location_t, tree, tree);
+static tree fold_builtin_round (location_t, tree, tree);
+static tree fold_builtin_int_roundingfn (location_t, tree, tree);
static tree fold_builtin_bitop (tree, tree);
-static tree fold_builtin_memory_op (tree, tree, tree, tree, bool, int);
-static tree fold_builtin_strchr (tree, tree, tree);
-static tree fold_builtin_memchr (tree, tree, tree, tree);
-static tree fold_builtin_memcmp (tree, tree, tree);
-static tree fold_builtin_strcmp (tree, tree);
-static tree fold_builtin_strncmp (tree, tree, tree);
-static tree fold_builtin_signbit (tree, tree);
-static tree fold_builtin_copysign (tree, tree, tree, tree);
-static tree fold_builtin_isascii (tree);
-static tree fold_builtin_toascii (tree);
-static tree fold_builtin_isdigit (tree);
-static tree fold_builtin_fabs (tree, tree);
-static tree fold_builtin_abs (tree, tree);
-static tree fold_builtin_unordered_cmp (tree, tree, tree, enum tree_code,
+static tree fold_builtin_memory_op (location_t, tree, tree, tree, tree, bool, int);
+static tree fold_builtin_strchr (location_t, tree, tree, tree);
+static tree fold_builtin_memchr (location_t, tree, tree, tree, tree);
+static tree fold_builtin_memcmp (location_t, tree, tree, tree);
+static tree fold_builtin_strcmp (location_t, tree, tree);
+static tree fold_builtin_strncmp (location_t, tree, tree, tree);
+static tree fold_builtin_signbit (location_t, tree, tree);
+static tree fold_builtin_copysign (location_t, tree, tree, tree, tree);
+static tree fold_builtin_isascii (location_t, tree);
+static tree fold_builtin_toascii (location_t, tree);
+static tree fold_builtin_isdigit (location_t, tree);
+static tree fold_builtin_fabs (location_t, tree, tree);
+static tree fold_builtin_abs (location_t, tree, tree);
+static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code,
enum tree_code);
-static tree fold_builtin_n (tree, tree *, int, bool);
-static tree fold_builtin_0 (tree, bool);
-static tree fold_builtin_1 (tree, tree, bool);
-static tree fold_builtin_2 (tree, tree, tree, bool);
-static tree fold_builtin_3 (tree, tree, tree, tree, bool);
-static tree fold_builtin_4 (tree, tree, tree, tree, tree, bool);
-static tree fold_builtin_varargs (tree, tree, bool);
-
-static tree fold_builtin_strpbrk (tree, tree, tree);
-static tree fold_builtin_strstr (tree, tree, tree);
-static tree fold_builtin_strrchr (tree, tree, tree);
-static tree fold_builtin_strcat (tree, tree);
-static tree fold_builtin_strncat (tree, tree, tree);
-static tree fold_builtin_strspn (tree, tree);
-static tree fold_builtin_strcspn (tree, tree);
-static tree fold_builtin_sprintf (tree, tree, tree, int);
+static tree fold_builtin_n (location_t, tree, tree *, int, bool);
+static tree fold_builtin_0 (location_t, tree, bool);
+static tree fold_builtin_1 (location_t, tree, tree, bool);
+static tree fold_builtin_2 (location_t, tree, tree, tree, bool);
+static tree fold_builtin_3 (location_t, tree, tree, tree, tree, bool);
+static tree fold_builtin_4 (location_t, tree, tree, tree, tree, tree, bool);
+static tree fold_builtin_varargs (location_t, tree, tree, bool);
+
+static tree fold_builtin_strpbrk (location_t, tree, tree, tree);
+static tree fold_builtin_strstr (location_t, tree, tree, tree);
+static tree fold_builtin_strrchr (location_t, tree, tree, tree);
+static tree fold_builtin_strcat (location_t, tree, tree);
+static tree fold_builtin_strncat (location_t, tree, tree, tree);
+static tree fold_builtin_strspn (location_t, tree, tree);
+static tree fold_builtin_strcspn (location_t, tree, tree);
+static tree fold_builtin_sprintf (location_t, tree, tree, tree, int);
static rtx expand_builtin_object_size (tree);
static rtx expand_builtin_memory_chk (tree, rtx, enum machine_mode,
@@ -219,11 +219,11 @@ static void maybe_emit_chk_warning (tree, enum built_in_function);
static void maybe_emit_sprintf_chk_warning (tree, enum built_in_function);
static void maybe_emit_free_warning (tree);
static tree fold_builtin_object_size (tree, tree);
-static tree fold_builtin_strcat_chk (tree, tree, tree, tree);
-static tree fold_builtin_strncat_chk (tree, tree, tree, tree, tree);
-static tree fold_builtin_sprintf_chk (tree, enum built_in_function);
-static tree fold_builtin_printf (tree, tree, tree, bool, enum built_in_function);
-static tree fold_builtin_fprintf (tree, tree, tree, tree, bool,
+static tree fold_builtin_strcat_chk (location_t, tree, tree, tree, tree);
+static tree fold_builtin_strncat_chk (location_t, tree, tree, tree, tree, tree);
+static tree fold_builtin_sprintf_chk (location_t, tree, enum built_in_function);
+static tree fold_builtin_printf (location_t, tree, tree, tree, bool, enum built_in_function);
+static tree fold_builtin_fprintf (location_t, tree, tree, tree, tree, bool,
enum built_in_function);
static bool init_target_chars (void);
@@ -482,7 +482,7 @@ c_strlen (tree src, int only_value)
and return that. This would perhaps not be valid if we were dealing
with named arrays in addition to literal string constants. */
- return size_diffop (size_int (max), offset_node);
+ return size_diffop_loc (input_location, size_int (max), offset_node);
}
/* We have a known offset into the string. Start searching there for
@@ -2268,6 +2268,7 @@ expand_builtin_interclass_mathfn (tree exp, rtx target, rtx subtarget)
enum machine_mode mode;
bool errno_set = false;
tree arg;
+ location_t loc = EXPR_LOCATION (exp);
if (!validate_arglist (exp, REAL_TYPE, VOID_TYPE))
return NULL_RTX;
@@ -2342,7 +2343,7 @@ expand_builtin_interclass_mathfn (tree exp, rtx target, rtx subtarget)
get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf));
real_from_string (&r, buf);
result = build_call_expr (isgr_fn, 2,
- fold_build1 (ABS_EXPR, type, arg),
+ fold_build1_loc (loc, ABS_EXPR, type, arg),
build_real (type, r));
return expand_expr (result, target, VOIDmode, EXPAND_NORMAL);
}
@@ -2358,7 +2359,7 @@ expand_builtin_interclass_mathfn (tree exp, rtx target, rtx subtarget)
get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf));
real_from_string (&r, buf);
result = build_call_expr (isle_fn, 2,
- fold_build1 (ABS_EXPR, type, arg),
+ fold_build1_loc (loc, ABS_EXPR, type, arg),
build_real (type, r));
return expand_expr (result, target, VOIDmode, EXPAND_NORMAL);
}
@@ -2376,7 +2377,7 @@ expand_builtin_interclass_mathfn (tree exp, rtx target, rtx subtarget)
real_from_string (&rmax, buf);
sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (mode)->emin - 1);
real_from_string (&rmin, buf);
- arg = builtin_save_expr (fold_build1 (ABS_EXPR, type, arg));
+ arg = builtin_save_expr (fold_build1_loc (loc, ABS_EXPR, type, arg));
result = build_call_expr (isle_fn, 2, arg,
build_real (type, rmax));
result = fold_build2 (BIT_AND_EXPR, integer_type_node, result,
@@ -2405,6 +2406,7 @@ expand_builtin_sincos (tree exp)
enum machine_mode mode;
tree arg, sinp, cosp;
int result;
+ location_t loc = EXPR_LOCATION (exp);
if (!validate_arglist (exp, REAL_TYPE,
POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
@@ -2425,8 +2427,8 @@ expand_builtin_sincos (tree exp)
target2 = gen_reg_rtx (mode);
op0 = expand_normal (arg);
- op1 = expand_normal (build_fold_indirect_ref (sinp));
- op2 = expand_normal (build_fold_indirect_ref (cosp));
+ op1 = expand_normal (build_fold_indirect_ref_loc (loc, sinp));
+ op2 = expand_normal (build_fold_indirect_ref_loc (loc, cosp));
/* Compute into target1 and target2.
Set TARGET to wherever the result comes back. */
@@ -2453,6 +2455,7 @@ expand_builtin_cexpi (tree exp, rtx target, rtx subtarget)
tree arg, type;
enum machine_mode mode;
rtx op0, op1, op2;
+ location_t loc = EXPR_LOCATION (exp);
if (!validate_arglist (exp, REAL_TYPE, VOID_TYPE))
return NULL_RTX;
@@ -2534,7 +2537,7 @@ expand_builtin_cexpi (tree exp, rtx target, rtx subtarget)
fn = build_fn_decl (name, fntype);
}
- narg = fold_build2 (COMPLEX_EXPR, ctype,
+ narg = fold_build2_loc (loc, COMPLEX_EXPR, ctype,
build_real (type, dconst0), arg);
/* Make sure not to fold the cexp call again. */
@@ -3269,7 +3272,8 @@ expand_builtin_strstr (tree exp, rtx target, enum machine_mode mode)
if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
{
tree type = TREE_TYPE (exp);
- tree result = fold_builtin_strstr (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_strstr (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1), type);
if (result)
return expand_expr (result, target, mode, EXPAND_NORMAL);
@@ -3287,7 +3291,8 @@ expand_builtin_strchr (tree exp, rtx target, enum machine_mode mode)
if (validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
{
tree type = TREE_TYPE (exp);
- tree result = fold_builtin_strchr (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_strchr (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1), type);
if (result)
return expand_expr (result, target, mode, EXPAND_NORMAL);
@@ -3307,7 +3312,8 @@ expand_builtin_strrchr (tree exp, rtx target, enum machine_mode mode)
if (validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
{
tree type = TREE_TYPE (exp);
- tree result = fold_builtin_strrchr (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_strrchr (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1), type);
if (result)
return expand_expr (result, target, mode, EXPAND_NORMAL);
@@ -3325,7 +3331,8 @@ expand_builtin_strpbrk (tree exp, rtx target, enum machine_mode mode)
if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
{
tree type = TREE_TYPE (exp);
- tree result = fold_builtin_strpbrk (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_strpbrk (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1), type);
if (result)
return expand_expr (result, target, mode, EXPAND_NORMAL);
@@ -3373,7 +3380,8 @@ expand_builtin_memcpy (tree exp, rtx target, enum machine_mode mode)
unsigned int dest_align
= get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
rtx dest_mem, src_mem, dest_addr, len_rtx;
- tree result = fold_builtin_memory_op (dest, src, len,
+ tree result = fold_builtin_memory_op (EXPR_LOCATION (exp),
+ dest, src, len,
TREE_TYPE (TREE_TYPE (fndecl)),
false, /*endp=*/0);
HOST_WIDE_INT expected_size = -1;
@@ -3504,7 +3512,8 @@ expand_builtin_mempcpy_args (tree dest, tree src, tree len, tree type,
unsigned int dest_align
= get_pointer_alignment (dest, BIGGEST_ALIGNMENT);
rtx dest_mem, src_mem, len_rtx;
- tree result = fold_builtin_memory_op (dest, src, len, type, false, endp);
+ tree result = fold_builtin_memory_op (UNKNOWN_LOCATION,
+ dest, src, len, type, false, endp);
if (result)
{
@@ -3599,7 +3608,8 @@ expand_builtin_memmove_args (tree dest, tree src, tree len,
tree type, rtx target, enum machine_mode mode,
int ignore)
{
- tree result = fold_builtin_memory_op (dest, src, len, type, ignore, /*endp=*/3);
+ tree result = fold_builtin_memory_op (UNKNOWN_LOCATION,
+ dest, src, len, type, ignore, /*endp=*/3);
if (result)
{
@@ -3625,6 +3635,7 @@ expand_builtin_bcopy (tree exp, int ignore)
{
tree type = TREE_TYPE (exp);
tree src, dest, size;
+ location_t loc = EXPR_LOCATION (exp);
if (!validate_arglist (exp,
POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
@@ -3638,7 +3649,7 @@ expand_builtin_bcopy (tree exp, int ignore)
This is done this way so that if it isn't expanded inline, we fall
back to calling bcopy instead of memmove. */
return expand_builtin_memmove_args (dest, src,
- fold_convert (sizetype, size),
+ fold_convert_loc (loc, sizetype, size),
type, const0_rtx, VOIDmode,
ignore);
}
@@ -3737,7 +3748,8 @@ static rtx
expand_builtin_strcpy_args (tree fndecl, tree dest, tree src,
rtx target, enum machine_mode mode)
{
- tree result = fold_builtin_strcpy (fndecl, dest, src, 0);
+ tree result = fold_builtin_strcpy (UNKNOWN_LOCATION,
+ fndecl, dest, src, 0);
if (result)
return expand_expr (result, target, mode, EXPAND_NORMAL);
return expand_movstr (dest, src, target, /*endp=*/0);
@@ -3753,6 +3765,7 @@ static rtx
expand_builtin_stpcpy (tree exp, rtx target, enum machine_mode mode)
{
tree dst, src;
+ location_t loc = EXPR_LOCATION (exp);
if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
return NULL_RTX;
@@ -3787,7 +3800,7 @@ expand_builtin_stpcpy (tree exp, rtx target, enum machine_mode mode)
if (! c_getstr (src) || ! (len = c_strlen (src, 0)))
return expand_movstr (dst, src, target, /*endp=*/2);
- lenp1 = size_binop (PLUS_EXPR, len, ssize_int (1));
+ lenp1 = size_binop_loc (loc, PLUS_EXPR, len, ssize_int (1));
ret = expand_builtin_mempcpy_args (dst, src, lenp1, TREE_TYPE (exp),
target, mode, /*endp=*/2);
@@ -3851,6 +3864,7 @@ static rtx
expand_builtin_strncpy (tree exp, rtx target, enum machine_mode mode)
{
tree fndecl = get_callee_fndecl (exp);
+ location_t loc = EXPR_LOCATION (exp);
if (validate_arglist (exp,
POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
@@ -3859,7 +3873,8 @@ expand_builtin_strncpy (tree exp, rtx target, enum machine_mode mode)
tree src = CALL_EXPR_ARG (exp, 1);
tree len = CALL_EXPR_ARG (exp, 2);
tree slen = c_strlen (src, 1);
- tree result = fold_builtin_strncpy (fndecl, dest, src, len, slen);
+ tree result = fold_builtin_strncpy (EXPR_LOCATION (exp),
+ fndecl, dest, src, len, slen);
if (result)
{
@@ -3876,7 +3891,7 @@ expand_builtin_strncpy (tree exp, rtx target, enum machine_mode mode)
if (!host_integerp (len, 1) || !slen || !host_integerp (slen, 1))
return NULL_RTX;
- slen = size_binop (PLUS_EXPR, slen, ssize_int (1));
+ slen = size_binop_loc (loc, PLUS_EXPR, slen, ssize_int (1));
/* We're required to pad with trailing zeros if the requested
len is greater than strlen(s2)+1. In that case try to
@@ -4106,6 +4121,7 @@ static rtx
expand_builtin_bzero (tree exp)
{
tree dest, size;
+ location_t loc = EXPR_LOCATION (exp);
if (!validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
return NULL_RTX;
@@ -4119,7 +4135,7 @@ expand_builtin_bzero (tree exp)
calling bzero instead of memset. */
return expand_builtin_memset_args (dest, integer_zero_node,
- fold_convert (sizetype, size),
+ fold_convert_loc (loc, sizetype, size),
const0_rtx, VOIDmode, exp);
}
@@ -4134,7 +4150,8 @@ expand_builtin_memchr (tree exp, rtx target, enum machine_mode mode)
INTEGER_TYPE, VOID_TYPE))
{
tree type = TREE_TYPE (exp);
- tree result = fold_builtin_memchr (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_memchr (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1),
CALL_EXPR_ARG (exp, 2), type);
if (result)
@@ -4151,12 +4168,15 @@ expand_builtin_memchr (tree exp, rtx target, enum machine_mode mode)
static rtx
expand_builtin_memcmp (tree exp, rtx target, enum machine_mode mode)
{
+ location_t loc = EXPR_LOCATION (exp);
+
if (!validate_arglist (exp,
POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
return NULL_RTX;
else
{
- tree result = fold_builtin_memcmp (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_memcmp (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1),
CALL_EXPR_ARG (exp, 2));
if (result)
@@ -4203,7 +4223,7 @@ expand_builtin_memcmp (tree exp, rtx target, enum machine_mode mode)
arg1_rtx = get_memory_rtx (arg1, len);
arg2_rtx = get_memory_rtx (arg2, len);
- arg3_rtx = expand_normal (fold_convert (sizetype, len));
+ arg3_rtx = expand_normal (fold_convert_loc (loc, sizetype, len));
/* Set MEM_SIZE as appropriate. */
if (CONST_INT_P (arg3_rtx))
@@ -4261,11 +4281,14 @@ expand_builtin_memcmp (tree exp, rtx target, enum machine_mode mode)
static rtx
expand_builtin_strcmp (tree exp, rtx target, enum machine_mode mode)
{
+ location_t loc = EXPR_LOCATION (exp);
+
if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
return NULL_RTX;
else
{
- tree result = fold_builtin_strcmp (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_strcmp (loc,
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1));
if (result)
return expand_expr (result, target, mode, EXPAND_NORMAL);
@@ -4410,12 +4433,15 @@ expand_builtin_strcmp (tree exp, rtx target, enum machine_mode mode)
static rtx
expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode)
{
+ location_t loc = EXPR_LOCATION (exp);
+
if (!validate_arglist (exp,
POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
return NULL_RTX;
else
{
- tree result = fold_builtin_strncmp (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_strncmp (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1),
CALL_EXPR_ARG (exp, 2));
if (result)
@@ -4447,9 +4473,9 @@ expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode)
len2 = c_strlen (arg2, 1);
if (len1)
- len1 = size_binop (PLUS_EXPR, ssize_int (1), len1);
+ len1 = size_binop_loc (loc, PLUS_EXPR, ssize_int (1), len1);
if (len2)
- len2 = size_binop (PLUS_EXPR, ssize_int (1), len2);
+ len2 = size_binop_loc (loc, PLUS_EXPR, ssize_int (1), len2);
/* If we don't have a constant length for the first, use the length
of the second, if we know it. We don't require a constant for
@@ -4480,8 +4506,8 @@ expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode)
return NULL_RTX;
/* The actual new length parameter is MIN(len,arg3). */
- len = fold_build2 (MIN_EXPR, TREE_TYPE (len), len,
- fold_convert (TREE_TYPE (len), arg3));
+ len = fold_build2_loc (loc, MIN_EXPR, TREE_TYPE (len), len,
+ fold_convert_loc (loc, TREE_TYPE (len), arg3));
/* If we don't have POINTER_TYPE, call the function. */
if (arg1_align == 0 || arg2_align == 0)
@@ -4537,6 +4563,8 @@ expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode)
static rtx
expand_builtin_strcat (tree fndecl, tree exp, rtx target, enum machine_mode mode)
{
+ location_t loc = EXPR_LOCATION (exp);
+
if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
return NULL_RTX;
else
@@ -4566,7 +4594,8 @@ expand_builtin_strcat (tree fndecl, tree exp, rtx target, enum machine_mode mode
newdst = build_call_expr (strlen_fn, 1, dst);
/* Create (dst p+ strlen (dst)). */
- newdst = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dst), dst, newdst);
+ newdst = fold_build2_loc (loc, POINTER_PLUS_EXPR,
+ TREE_TYPE (dst), dst, newdst);
newdst = builtin_save_expr (newdst);
if (!expand_builtin_strcpy_args (fndecl, newdst, newsrc, target, mode))
@@ -4597,7 +4626,8 @@ expand_builtin_strncat (tree exp, rtx target, enum machine_mode mode)
if (validate_arglist (exp,
POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
{
- tree result = fold_builtin_strncat (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_strncat (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1),
CALL_EXPR_ARG (exp, 2));
if (result)
@@ -4615,7 +4645,8 @@ expand_builtin_strspn (tree exp, rtx target, enum machine_mode mode)
{
if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
{
- tree result = fold_builtin_strspn (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_strspn (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1));
if (result)
return expand_expr (result, target, mode, EXPAND_NORMAL);
@@ -4632,7 +4663,8 @@ expand_builtin_strcspn (tree exp, rtx target, enum machine_mode mode)
{
if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
{
- tree result = fold_builtin_strcspn (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_strcspn (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1));
if (result)
return expand_expr (result, target, mode, EXPAND_NORMAL);
@@ -4726,7 +4758,7 @@ expand_builtin_next_arg (void)
from multiple evaluations. */
static tree
-stabilize_va_list (tree valist, int needs_lvalue)
+stabilize_va_list_loc (location_t loc, tree valist, int needs_lvalue)
{
tree vatype = targetm.canonical_va_list_type (TREE_TYPE (valist));
@@ -4744,7 +4776,7 @@ stabilize_va_list (tree valist, int needs_lvalue)
if (TREE_CODE (TREE_TYPE (valist)) == ARRAY_TYPE)
{
tree p1 = build_pointer_type (TREE_TYPE (vatype));
- valist = build_fold_addr_expr_with_type (valist, p1);
+ valist = build_fold_addr_expr_with_type_loc (loc, valist, p1);
}
}
else
@@ -4757,13 +4789,13 @@ stabilize_va_list (tree valist, int needs_lvalue)
return valist;
pt = build_pointer_type (vatype);
- valist = fold_build1 (ADDR_EXPR, pt, valist);
+ valist = fold_build1_loc (loc, ADDR_EXPR, pt, valist);
TREE_SIDE_EFFECTS (valist) = 1;
}
if (TREE_SIDE_EFFECTS (valist))
valist = save_expr (valist);
- valist = build_fold_indirect_ref (valist);
+ valist = build_fold_indirect_ref_loc (loc, valist);
}
return valist;
@@ -4837,10 +4869,11 @@ expand_builtin_va_start (tree exp)
{
rtx nextarg;
tree valist;
+ location_t loc = EXPR_LOCATION (exp);
if (call_expr_nargs (exp) < 2)
{
- error ("too few arguments to function %<va_start%>");
+ error_at (loc, "too few arguments to function %<va_start%>");
return const0_rtx;
}
@@ -4848,7 +4881,7 @@ expand_builtin_va_start (tree exp)
return const0_rtx;
nextarg = expand_builtin_next_arg ();
- valist = stabilize_va_list (CALL_EXPR_ARG (exp, 0), 1);
+ valist = stabilize_va_list_loc (loc, CALL_EXPR_ARG (exp, 0), 1);
if (targetm.expand_builtin_va_start)
targetm.expand_builtin_va_start (valist, nextarg);
@@ -4901,7 +4934,8 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
&& !integer_zerop (TYPE_SIZE (type)))
{
t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp,
- fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (valist),
+ fold_build2 (POINTER_PLUS_EXPR,
+ TREE_TYPE (valist),
valist_tmp, size_int (boundary - 1)));
gimplify_and_add (t, pre_p);
@@ -4937,10 +4971,12 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
if (PAD_VARARGS_DOWN && !integer_zerop (rounded_size))
{
/* Small args are padded downward. */
- t = fold_build2 (GT_EXPR, sizetype, rounded_size, size_int (align));
+ t = fold_build2_loc (input_location, GT_EXPR, sizetype,
+ rounded_size, size_int (align));
t = fold_build3 (COND_EXPR, sizetype, t, size_zero_node,
size_binop (MINUS_EXPR, rounded_size, type_size));
- addr = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (addr), addr, t);
+ addr = fold_build2 (POINTER_PLUS_EXPR,
+ TREE_TYPE (addr), addr, t);
}
/* Compute new value for AP. */
@@ -4961,7 +4997,7 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
tree
build_va_arg_indirect_ref (tree addr)
{
- addr = build_fold_indirect_ref (addr);
+ addr = build_fold_indirect_ref_loc (EXPR_LOCATION (addr), addr);
if (flag_mudflap) /* Don't instrument va_arg INDIRECT_REF. */
mf_mark (addr);
@@ -4989,8 +5025,7 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
tree valist = TREE_OPERAND (*expr_p, 0);
tree type = TREE_TYPE (*expr_p);
tree t;
- location_t loc = EXPR_HAS_LOCATION (*expr_p) ? EXPR_LOCATION (*expr_p) :
- UNKNOWN_LOCATION;
+ location_t loc = EXPR_LOCATION (*expr_p);
/* Verify that valist is of the proper type. */
have_va_type = TREE_TYPE (valist);
@@ -5032,7 +5067,8 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
/* Before the abort, allow the evaluation of the va_list
expression to exit or longjmp. */
gimplify_and_add (valist, pre_p);
- t = build_call_expr (implicit_built_in_decls[BUILT_IN_TRAP], 0);
+ t = build_call_expr_loc (loc,
+ implicit_built_in_decls[BUILT_IN_TRAP], 0);
gimplify_and_add (t, pre_p);
/* This is dead code, but go ahead and finish so that the
@@ -5053,7 +5089,8 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
if (TREE_CODE (TREE_TYPE (valist)) == ARRAY_TYPE)
{
tree p1 = build_pointer_type (TREE_TYPE (have_va_type));
- valist = fold_convert (p1, build_fold_addr_expr (valist));
+ valist = fold_convert_loc (loc, p1,
+ build_fold_addr_expr_loc (loc, valist));
}
gimplify_expr (&valist, pre_p, post_p, is_gimple_val, fb_rvalue);
@@ -5067,6 +5104,7 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
return GS_ALL_DONE;
*expr_p = targetm.gimplify_va_arg_expr (valist, type, pre_p, post_p);
+ SET_EXPR_LOCATION (*expr_p, loc);
return GS_OK;
}
}
@@ -5094,12 +5132,13 @@ static rtx
expand_builtin_va_copy (tree exp)
{
tree dst, src, t;
+ location_t loc = EXPR_LOCATION (exp);
dst = CALL_EXPR_ARG (exp, 0);
src = CALL_EXPR_ARG (exp, 1);
- dst = stabilize_va_list (dst, 1);
- src = stabilize_va_list (src, 0);
+ dst = stabilize_va_list_loc (loc, dst, 1);
+ src = stabilize_va_list_loc (loc, src, 0);
gcc_assert (cfun != NULL && cfun->decl != NULL_TREE);
@@ -5270,7 +5309,8 @@ expand_builtin_fputs (tree exp, rtx target, bool unlocked)
/* Verify the arguments in the original call. */
if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
{
- tree result = fold_builtin_fputs (CALL_EXPR_ARG (exp, 0),
+ tree result = fold_builtin_fputs (EXPR_LOCATION (exp),
+ CALL_EXPR_ARG (exp, 0),
CALL_EXPR_ARG (exp, 1),
(target == const0_rtx),
unlocked, NULL_TREE);
@@ -5846,6 +5886,7 @@ expand_builtin_signbit (tree exp, rtx target)
int word, bitpos;
enum insn_code icode;
rtx temp;
+ location_t loc = EXPR_LOCATION (exp);
if (!validate_arglist (exp, REAL_TYPE, VOID_TYPE))
return NULL_RTX;
@@ -5879,7 +5920,7 @@ expand_builtin_signbit (tree exp, rtx target)
if (fmt->has_signed_zero && HONOR_SIGNED_ZEROS (fmode))
return NULL_RTX;
- arg = fold_build2 (LT_EXPR, TREE_TYPE (exp), arg,
+ arg = fold_build2_loc (loc, LT_EXPR, TREE_TYPE (exp), arg,
build_real (TREE_TYPE (arg), dconst0));
return expand_expr (arg, target, VOIDmode, EXPAND_NORMAL);
}
@@ -6007,7 +6048,7 @@ expand_builtin_fork_or_exec (tree fn, tree exp, rtx target, int ignore)
TREE_NOTHROW (decl) = 1;
DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
DECL_VISIBILITY_SPECIFIED (decl) = 1;
- call = rewrite_call_expr (exp, 0, decl, 0);
+ call = rewrite_call_expr (EXPR_LOCATION (exp), exp, 0, decl, 0);
return expand_call (call, target, ignore);
}
@@ -7292,7 +7333,7 @@ fold_builtin_constant_p (tree arg)
return it as a truthvalue. */
static tree
-build_builtin_expect_predicate (tree pred, tree expected)
+build_builtin_expect_predicate (location_t loc, tree pred, tree expected)
{
tree fn, arg_types, pred_type, expected_type, call_expr, ret_type;
@@ -7302,9 +7343,9 @@ build_builtin_expect_predicate (tree pred, tree expected)
pred_type = TREE_VALUE (arg_types);
expected_type = TREE_VALUE (TREE_CHAIN (arg_types));
- pred = fold_convert (pred_type, pred);
- expected = fold_convert (expected_type, expected);
- call_expr = build_call_expr (fn, 2, pred, expected);
+ pred = fold_convert_loc (loc, pred_type, pred);
+ expected = fold_convert_loc (loc, expected_type, expected);
+ call_expr = build_call_expr_loc (loc, fn, 2, pred, expected);
return build2 (NE_EXPR, TREE_TYPE (pred), call_expr,
build_int_cst (ret_type, 0));
@@ -7314,7 +7355,7 @@ build_builtin_expect_predicate (tree pred, tree expected)
NULL_TREE if no simplification is possible. */
static tree
-fold_builtin_expect (tree arg0, tree arg1)
+fold_builtin_expect (location_t loc, tree arg0, tree arg1)
{
tree inner, fndecl;
enum tree_code code;
@@ -7347,11 +7388,11 @@ fold_builtin_expect (tree arg0, tree arg1)
tree op0 = TREE_OPERAND (inner, 0);
tree op1 = TREE_OPERAND (inner, 1);
- op0 = build_builtin_expect_predicate (op0, arg1);
- op1 = build_builtin_expect_predicate (op1, arg1);
+ op0 = build_builtin_expect_predicate (loc, op0, arg1);
+ op1 = build_builtin_expect_predicate (loc, op1, arg1);
inner = build2 (code, TREE_TYPE (inner), op0, op1);
- return fold_convert (TREE_TYPE (arg0), inner);
+ return fold_convert_loc (loc, TREE_TYPE (arg0), inner);
}
/* If the argument isn't invariant then there's nothing else we can do. */
@@ -7395,7 +7436,7 @@ fold_builtin_classify_type (tree arg)
/* Fold a call to __builtin_strlen with argument ARG. */
static tree
-fold_builtin_strlen (tree arg)
+fold_builtin_strlen (location_t loc, tree arg)
{
if (!validate_arg (arg, POINTER_TYPE))
return NULL_TREE;
@@ -7407,7 +7448,7 @@ fold_builtin_strlen (tree arg)
{
/* Convert from the internal "sizetype" type to "size_t". */
if (size_type_node)
- len = fold_convert (size_type_node, len);
+ len = fold_convert_loc (loc, size_type_node, len);
return len;
}
@@ -7418,7 +7459,7 @@ fold_builtin_strlen (tree arg)
/* Fold a call to __builtin_inf or __builtin_huge_val. */
static tree
-fold_builtin_inf (tree type, int warn)
+fold_builtin_inf (location_t loc, tree type, int warn)
{
REAL_VALUE_TYPE real;
@@ -7430,7 +7471,7 @@ fold_builtin_inf (tree type, int warn)
Thus we pedwarn to ensure this constraint violation is
diagnosed. */
if (!MODE_HAS_INFINITIES (TYPE_MODE (type)) && warn)
- pedwarn (input_location, 0, "target format does not support infinity");
+ pedwarn (loc, 0, "target format does not support infinity");
real_inf (&real);
return build_real (type, real);
@@ -7533,7 +7574,7 @@ integer_valued_real_p (tree t)
Do the transformation for a call with argument ARG. */
static tree
-fold_trunc_transparent_mathfn (tree fndecl, tree arg)
+fold_trunc_transparent_mathfn (location_t loc, tree fndecl, tree arg)
{
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
@@ -7558,9 +7599,11 @@ fold_trunc_transparent_mathfn (tree fndecl, tree arg)
if (TYPE_PRECISION (newtype) < TYPE_PRECISION (ftype)
&& (decl = mathfn_built_in (newtype, fcode)))
- return fold_convert (ftype,
- build_call_expr (decl, 1,
- fold_convert (newtype, arg0)));
+ return fold_convert_loc (loc, ftype,
+ build_call_expr_loc (loc, decl, 1,
+ fold_convert_loc (loc,
+ newtype,
+ arg0)));
}
return NULL_TREE;
}
@@ -7570,7 +7613,7 @@ fold_trunc_transparent_mathfn (tree fndecl, tree arg)
Do the transformation for a call with argument ARG. */
static tree
-fold_fixed_mathfn (tree fndecl, tree arg)
+fold_fixed_mathfn (location_t loc, tree fndecl, tree arg)
{
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
@@ -7580,7 +7623,8 @@ fold_fixed_mathfn (tree fndecl, tree arg)
/* If argument is already integer valued, and we don't need to worry
about setting errno, there's no need to perform rounding. */
if (! flag_errno_math && integer_valued_real_p (arg))
- return fold_build1 (FIX_TRUNC_EXPR, TREE_TYPE (TREE_TYPE (fndecl)), arg);
+ return fold_build1_loc (loc, FIX_TRUNC_EXPR,
+ TREE_TYPE (TREE_TYPE (fndecl)), arg);
if (optimize)
{
@@ -7591,7 +7635,8 @@ fold_fixed_mathfn (tree fndecl, tree arg)
if (TYPE_PRECISION (newtype) < TYPE_PRECISION (ftype)
&& (decl = mathfn_built_in (newtype, fcode)))
- return build_call_expr (decl, 1, fold_convert (newtype, arg0));
+ return build_call_expr_loc (loc, decl, 1,
+ fold_convert_loc (loc, newtype, arg0));
}
/* Canonicalize llround (x) to lround (x) on LP64 targets where
@@ -7624,8 +7669,9 @@ fold_fixed_mathfn (tree fndecl, tree arg)
if (newfn)
{
- tree newcall = build_call_expr(newfn, 1, arg);
- return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), newcall);
+ tree newcall = build_call_expr_loc (loc, newfn, 1, arg);
+ return fold_convert_loc (loc,
+ TREE_TYPE (TREE_TYPE (fndecl)), newcall);
}
}
@@ -7636,7 +7682,7 @@ fold_fixed_mathfn (tree fndecl, tree arg)
return type. Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_cabs (tree arg, tree type, tree fndecl)
+fold_builtin_cabs (location_t loc, tree arg, tree type, tree fndecl)
{
tree res;
@@ -7657,9 +7703,9 @@ fold_builtin_cabs (tree arg, tree type, tree fndecl)
/* If either part is zero, cabs is fabs of the other. */
if (real_zerop (real))
- return fold_build1 (ABS_EXPR, type, imag);
+ return fold_build1_loc (loc, ABS_EXPR, type, imag);
if (real_zerop (imag))
- return fold_build1 (ABS_EXPR, type, real);
+ return fold_build1_loc (loc, ABS_EXPR, type, real);
/* cabs(x+xi) -> fabs(x)*sqrt(2). */
if (flag_unsafe_math_optimizations
@@ -7668,8 +7714,8 @@ fold_builtin_cabs (tree arg, tree type, tree fndecl)
const REAL_VALUE_TYPE sqrt2_trunc
= real_value_truncate (TYPE_MODE (type), dconst_sqrt2 ());
STRIP_NOPS (real);
- return fold_build2 (MULT_EXPR, type,
- fold_build1 (ABS_EXPR, type, real),
+ return fold_build2_loc (loc, MULT_EXPR, type,
+ fold_build1_loc (loc, ABS_EXPR, type, real),
build_real (type, sqrt2_trunc));
}
}
@@ -7677,7 +7723,7 @@ fold_builtin_cabs (tree arg, tree type, tree fndecl)
/* Optimize cabs(-z) and cabs(conj(z)) as cabs(z). */
if (TREE_CODE (arg) == NEGATE_EXPR
|| TREE_CODE (arg) == CONJ_EXPR)
- return build_call_expr (fndecl, 1, TREE_OPERAND (arg, 0));
+ return build_call_expr_loc (loc, fndecl, 1, TREE_OPERAND (arg, 0));
/* Don't do this when optimizing for size. */
if (flag_unsafe_math_optimizations
@@ -7691,19 +7737,19 @@ fold_builtin_cabs (tree arg, tree type, tree fndecl)
arg = builtin_save_expr (arg);
- rpart = fold_build1 (REALPART_EXPR, type, arg);
- ipart = fold_build1 (IMAGPART_EXPR, type, arg);
+ rpart = fold_build1_loc (loc, REALPART_EXPR, type, arg);
+ ipart = fold_build1_loc (loc, IMAGPART_EXPR, type, arg);
rpart = builtin_save_expr (rpart);
ipart = builtin_save_expr (ipart);
- result = fold_build2 (PLUS_EXPR, type,
- fold_build2 (MULT_EXPR, type,
+ result = fold_build2_loc (loc, PLUS_EXPR, type,
+ fold_build2_loc (loc, MULT_EXPR, type,
rpart, rpart),
- fold_build2 (MULT_EXPR, type,
+ fold_build2_loc (loc, MULT_EXPR, type,
ipart, ipart));
- return build_call_expr (sqrtfn, 1, result);
+ return build_call_expr_loc (loc, sqrtfn, 1, result);
}
}
@@ -7714,7 +7760,7 @@ fold_builtin_cabs (tree arg, tree type, tree fndecl)
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_sqrt (tree arg, tree type)
+fold_builtin_sqrt (location_t loc, tree arg, tree type)
{
enum built_in_function fcode;
@@ -7732,10 +7778,10 @@ fold_builtin_sqrt (tree arg, tree type)
if (flag_unsafe_math_optimizations && BUILTIN_EXPONENT_P (fcode))
{
tree expfn = TREE_OPERAND (CALL_EXPR_FN (arg), 0);
- arg = fold_build2 (MULT_EXPR, type,
+ arg = fold_build2_loc (loc, MULT_EXPR, type,
CALL_EXPR_ARG (arg, 0),
build_real (type, dconsthalf));
- return build_call_expr (expfn, 1, arg);
+ return build_call_expr_loc (loc, expfn, 1, arg);
}
/* Optimize sqrt(Nroot(x)) -> pow(x,1/(2*N)). */
@@ -7760,7 +7806,7 @@ fold_builtin_sqrt (tree arg, tree type)
SET_REAL_EXP (&dconstroot, REAL_EXP (&dconstroot) - 1);
dconstroot = real_value_truncate (TYPE_MODE (type), dconstroot);
tree_root = build_real (type, dconstroot);
- return build_call_expr (powfn, 2, arg0, tree_root);
+ return build_call_expr_loc (loc, powfn, 2, arg0, tree_root);
}
}
@@ -7776,9 +7822,9 @@ fold_builtin_sqrt (tree arg, tree type)
tree narg1;
if (!tree_expr_nonnegative_p (arg0))
arg0 = build1 (ABS_EXPR, type, arg0);
- narg1 = fold_build2 (MULT_EXPR, type, arg1,
+ narg1 = fold_build2_loc (loc, MULT_EXPR, type, arg1,
build_real (type, dconsthalf));
- return build_call_expr (powfn, 2, arg0, narg1);
+ return build_call_expr_loc (loc, powfn, 2, arg0, narg1);
}
return NULL_TREE;
@@ -7788,7 +7834,7 @@ fold_builtin_sqrt (tree arg, tree type)
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_cbrt (tree arg, tree type)
+fold_builtin_cbrt (location_t loc, tree arg, tree type)
{
const enum built_in_function fcode = builtin_mathfn_code (arg);
tree res;
@@ -7808,10 +7854,10 @@ fold_builtin_cbrt (tree arg, tree type)
tree expfn = TREE_OPERAND (CALL_EXPR_FN (arg), 0);
const REAL_VALUE_TYPE third_trunc =
real_value_truncate (TYPE_MODE (type), dconst_third ());
- arg = fold_build2 (MULT_EXPR, type,
+ arg = fold_build2_loc (loc, MULT_EXPR, type,
CALL_EXPR_ARG (arg, 0),
build_real (type, third_trunc));
- return build_call_expr (expfn, 1, arg);
+ return build_call_expr_loc (loc, expfn, 1, arg);
}
/* Optimize cbrt(sqrt(x)) -> pow(x,1/6). */
@@ -7828,7 +7874,7 @@ fold_builtin_cbrt (tree arg, tree type)
SET_REAL_EXP (&dconstroot, REAL_EXP (&dconstroot) - 1);
dconstroot = real_value_truncate (TYPE_MODE (type), dconstroot);
tree_root = build_real (type, dconstroot);
- return build_call_expr (powfn, 2, arg0, tree_root);
+ return build_call_expr_loc (loc, powfn, 2, arg0, tree_root);
}
}
@@ -7849,7 +7895,7 @@ fold_builtin_cbrt (tree arg, tree type)
dconst_third_ptr (), dconst_third_ptr ());
dconstroot = real_value_truncate (TYPE_MODE (type), dconstroot);
tree_root = build_real (type, dconstroot);
- return build_call_expr (powfn, 2, arg0, tree_root);
+ return build_call_expr_loc (loc, powfn, 2, arg0, tree_root);
}
}
}
@@ -7866,9 +7912,9 @@ fold_builtin_cbrt (tree arg, tree type)
tree powfn = TREE_OPERAND (CALL_EXPR_FN (arg), 0);
const REAL_VALUE_TYPE dconstroot
= real_value_truncate (TYPE_MODE (type), dconst_third ());
- tree narg01 = fold_build2 (MULT_EXPR, type, arg01,
+ tree narg01 = fold_build2_loc (loc, MULT_EXPR, type, arg01,
build_real (type, dconstroot));
- return build_call_expr (powfn, 2, arg00, narg01);
+ return build_call_expr_loc (loc, powfn, 2, arg00, narg01);
}
}
}
@@ -7880,7 +7926,8 @@ fold_builtin_cbrt (tree arg, tree type)
simplification can be made. */
static tree
-fold_builtin_cos (tree arg, tree type, tree fndecl)
+fold_builtin_cos (location_t loc,
+ tree arg, tree type, tree fndecl)
{
tree res, narg;
@@ -7893,7 +7940,7 @@ fold_builtin_cos (tree arg, tree type, tree fndecl)
/* Optimize cos(-x) into cos (x). */
if ((narg = fold_strip_sign_ops (arg)))
- return build_call_expr (fndecl, 1, narg);
+ return build_call_expr_loc (loc, fndecl, 1, narg);
return NULL_TREE;
}
@@ -7902,7 +7949,7 @@ fold_builtin_cos (tree arg, tree type, tree fndecl)
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_cosh (tree arg, tree type, tree fndecl)
+fold_builtin_cosh (location_t loc, tree arg, tree type, tree fndecl)
{
if (validate_arg (arg, REAL_TYPE))
{
@@ -7914,7 +7961,7 @@ fold_builtin_cosh (tree arg, tree type, tree fndecl)
/* Optimize cosh(-x) into cosh (x). */
if ((narg = fold_strip_sign_ops (arg)))
- return build_call_expr (fndecl, 1, narg);
+ return build_call_expr_loc (loc, fndecl, 1, narg);
}
return NULL_TREE;
@@ -7925,7 +7972,8 @@ fold_builtin_cosh (tree arg, tree type, tree fndecl)
NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_ccos (tree arg, tree type ATTRIBUTE_UNUSED, tree fndecl,
+fold_builtin_ccos (location_t loc,
+ tree arg, tree type ATTRIBUTE_UNUSED, tree fndecl,
bool hyper ATTRIBUTE_UNUSED)
{
if (validate_arg (arg, COMPLEX_TYPE)
@@ -7941,7 +7989,7 @@ fold_builtin_ccos (tree arg, tree type ATTRIBUTE_UNUSED, tree fndecl,
/* Optimize fn(-x) into fn(x). */
if ((tmp = fold_strip_sign_ops (arg)))
- return build_call_expr (fndecl, 1, tmp);
+ return build_call_expr_loc (loc, fndecl, 1, tmp);
}
return NULL_TREE;
@@ -7978,7 +8026,8 @@ fold_builtin_tan (tree arg, tree type)
NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_sincos (tree arg0, tree arg1, tree arg2)
+fold_builtin_sincos (location_t loc,
+ tree arg0, tree arg1, tree arg2)
{
tree type;
tree res, fn, call;
@@ -8001,15 +8050,15 @@ fold_builtin_sincos (tree arg0, tree arg1, tree arg2)
if (!fn)
return NULL_TREE;
- call = build_call_expr (fn, 1, arg0);
+ call = build_call_expr_loc (loc, fn, 1, arg0);
call = builtin_save_expr (call);
return build2 (COMPOUND_EXPR, void_type_node,
build2 (MODIFY_EXPR, void_type_node,
- build_fold_indirect_ref (arg1),
+ build_fold_indirect_ref_loc (loc, arg1),
build1 (IMAGPART_EXPR, type, call)),
build2 (MODIFY_EXPR, void_type_node,
- build_fold_indirect_ref (arg2),
+ build_fold_indirect_ref_loc (loc, arg2),
build1 (REALPART_EXPR, type, call)));
}
@@ -8017,7 +8066,7 @@ fold_builtin_sincos (tree arg0, tree arg1, tree arg2)
NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_cexp (tree arg0, tree type)
+fold_builtin_cexp (location_t loc, tree arg0, tree type)
{
tree rtype;
tree realp, imagp, ifn;
@@ -8045,11 +8094,11 @@ fold_builtin_cexp (tree arg0, tree type)
if (!ifn)
return NULL_TREE;
- if ((realp = fold_unary (REALPART_EXPR, rtype, arg0))
+ if ((realp = fold_unary_loc (loc, REALPART_EXPR, rtype, arg0))
&& real_zerop (realp))
{
- tree narg = fold_build1 (IMAGPART_EXPR, rtype, arg0);
- return build_call_expr (ifn, 1, narg);
+ tree narg = fold_build1_loc (loc, IMAGPART_EXPR, rtype, arg0);
+ return build_call_expr_loc (loc, ifn, 1, narg);
}
/* In case we can easily decompose real and imaginary parts split cexp
@@ -8063,21 +8112,23 @@ fold_builtin_cexp (tree arg0, tree type)
if (!rfn)
return NULL_TREE;
- imagp = fold_unary (IMAGPART_EXPR, rtype, arg0);
+ imagp = fold_unary_loc (loc, IMAGPART_EXPR, rtype, arg0);
if (!imagp)
return NULL_TREE;
- icall = build_call_expr (ifn, 1, imagp);
+ icall = build_call_expr_loc (loc, ifn, 1, imagp);
icall = builtin_save_expr (icall);
- rcall = build_call_expr (rfn, 1, realp);
+ rcall = build_call_expr_loc (loc, rfn, 1, realp);
rcall = builtin_save_expr (rcall);
- return fold_build2 (COMPLEX_EXPR, type,
- fold_build2 (MULT_EXPR, rtype,
+ return fold_build2_loc (loc, COMPLEX_EXPR, type,
+ fold_build2_loc (loc, MULT_EXPR, rtype,
rcall,
- fold_build1 (REALPART_EXPR, rtype, icall)),
- fold_build2 (MULT_EXPR, rtype,
+ fold_build1_loc (loc, REALPART_EXPR,
+ rtype, icall)),
+ fold_build2_loc (loc, MULT_EXPR, rtype,
rcall,
- fold_build1 (IMAGPART_EXPR, rtype, icall)));
+ fold_build1_loc (loc, IMAGPART_EXPR,
+ rtype, icall)));
}
return NULL_TREE;
@@ -8087,7 +8138,7 @@ fold_builtin_cexp (tree arg0, tree type)
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_trunc (tree fndecl, tree arg)
+fold_builtin_trunc (location_t loc, tree fndecl, tree arg)
{
if (!validate_arg (arg, REAL_TYPE))
return NULL_TREE;
@@ -8103,14 +8154,14 @@ fold_builtin_trunc (tree fndecl, tree arg)
return build_real (type, r);
}
- return fold_trunc_transparent_mathfn (fndecl, arg);
+ return fold_trunc_transparent_mathfn (loc, fndecl, arg);
}
/* Fold function call to builtin floor, floorf or floorl with argument ARG.
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_floor (tree fndecl, tree arg)
+fold_builtin_floor (location_t loc, tree fndecl, tree arg)
{
if (!validate_arg (arg, REAL_TYPE))
return NULL_TREE;
@@ -8136,17 +8187,17 @@ fold_builtin_floor (tree fndecl, tree arg)
{
tree truncfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_TRUNC);
if (truncfn)
- return build_call_expr (truncfn, 1, arg);
+ return build_call_expr_loc (loc, truncfn, 1, arg);
}
- return fold_trunc_transparent_mathfn (fndecl, arg);
+ return fold_trunc_transparent_mathfn (loc, fndecl, arg);
}
/* Fold function call to builtin ceil, ceilf or ceill with argument ARG.
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_ceil (tree fndecl, tree arg)
+fold_builtin_ceil (location_t loc, tree fndecl, tree arg)
{
if (!validate_arg (arg, REAL_TYPE))
return NULL_TREE;
@@ -8167,14 +8218,14 @@ fold_builtin_ceil (tree fndecl, tree arg)
}
}
- return fold_trunc_transparent_mathfn (fndecl, arg);
+ return fold_trunc_transparent_mathfn (loc, fndecl, arg);
}
/* Fold function call to builtin round, roundf or roundl with argument ARG.
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_round (tree fndecl, tree arg)
+fold_builtin_round (location_t loc, tree fndecl, tree arg)
{
if (!validate_arg (arg, REAL_TYPE))
return NULL_TREE;
@@ -8195,7 +8246,7 @@ fold_builtin_round (tree fndecl, tree arg)
}
}
- return fold_trunc_transparent_mathfn (fndecl, arg);
+ return fold_trunc_transparent_mathfn (loc, fndecl, arg);
}
/* Fold function call to builtin lround, lroundf or lroundl (or the
@@ -8204,7 +8255,7 @@ fold_builtin_round (tree fndecl, tree arg)
can be made. */
static tree
-fold_builtin_int_roundingfn (tree fndecl, tree arg)
+fold_builtin_int_roundingfn (location_t loc, tree fndecl, tree arg)
{
if (!validate_arg (arg, REAL_TYPE))
return NULL_TREE;
@@ -8255,13 +8306,13 @@ fold_builtin_int_roundingfn (tree fndecl, tree arg)
CASE_FLT_FN (BUILT_IN_LLFLOOR):
/* Fold lfloor (x) where x is nonnegative to FIX_TRUNC (x). */
if (tree_expr_nonnegative_p (arg))
- return fold_build1 (FIX_TRUNC_EXPR, TREE_TYPE (TREE_TYPE (fndecl)),
- arg);
+ return fold_build1_loc (loc, FIX_TRUNC_EXPR,
+ TREE_TYPE (TREE_TYPE (fndecl)), arg);
break;
default:;
}
- return fold_fixed_mathfn (fndecl, arg);
+ return fold_fixed_mathfn (loc, fndecl, arg);
}
/* Fold function call to builtin ffs, clz, ctz, popcount and parity
@@ -8420,7 +8471,7 @@ fold_builtin_bswap (tree fndecl, tree arg)
FUNC is the corresponding MPFR logarithm function. */
static tree
-fold_builtin_logarithm (tree fndecl, tree arg,
+fold_builtin_logarithm (location_t loc, tree fndecl, tree arg,
int (*func)(mpfr_ptr, mpfr_srcptr, mp_rnd_t))
{
if (validate_arg (arg, REAL_TYPE))
@@ -8444,7 +8495,7 @@ fold_builtin_logarithm (tree fndecl, tree arg,
|| fcode == BUILT_IN_EXP2F
|| fcode == BUILT_IN_EXP2L))
|| (func == mpfr_log10 && (BUILTIN_EXP10_P (fcode)))))
- return fold_convert (type, CALL_EXPR_ARG (arg, 0));
+ return fold_convert_loc (loc, type, CALL_EXPR_ARG (arg, 0));
/* Optimize logN(func()) for various exponential functions. We
want to determine the value "x" and the power "exponent" in
@@ -8499,8 +8550,8 @@ fold_builtin_logarithm (tree fndecl, tree arg,
/* Now perform the optimization. */
if (x && exponent)
{
- tree logfn = build_call_expr (fndecl, 1, x);
- return fold_build2 (MULT_EXPR, type, exponent, logfn);
+ tree logfn = build_call_expr_loc (loc, fndecl, 1, x);
+ return fold_build2_loc (loc, MULT_EXPR, type, exponent, logfn);
}
}
}
@@ -8512,7 +8563,8 @@ fold_builtin_logarithm (tree fndecl, tree arg,
NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_hypot (tree fndecl, tree arg0, tree arg1, tree type)
+fold_builtin_hypot (location_t loc, tree fndecl,
+ tree arg0, tree arg1, tree type)
{
tree res, narg0, narg1;
@@ -8530,15 +8582,15 @@ fold_builtin_hypot (tree fndecl, tree arg0, tree arg1, tree type)
narg1 = fold_strip_sign_ops (arg1);
if (narg0 || narg1)
{
- return build_call_expr (fndecl, 2, narg0 ? narg0 : arg0,
+ return build_call_expr_loc (loc, fndecl, 2, narg0 ? narg0 : arg0,
narg1 ? narg1 : arg1);
}
/* If either argument is zero, hypot is fabs of the other. */
if (real_zerop (arg0))
- return fold_build1 (ABS_EXPR, type, arg1);
+ return fold_build1_loc (loc, ABS_EXPR, type, arg1);
else if (real_zerop (arg1))
- return fold_build1 (ABS_EXPR, type, arg0);
+ return fold_build1_loc (loc, ABS_EXPR, type, arg0);
/* hypot(x,x) -> fabs(x)*sqrt(2). */
if (flag_unsafe_math_optimizations
@@ -8546,8 +8598,8 @@ fold_builtin_hypot (tree fndecl, tree arg0, tree arg1, tree type)
{
const REAL_VALUE_TYPE sqrt2_trunc
= real_value_truncate (TYPE_MODE (type), dconst_sqrt2 ());
- return fold_build2 (MULT_EXPR, type,
- fold_build1 (ABS_EXPR, type, arg0),
+ return fold_build2_loc (loc, MULT_EXPR, type,
+ fold_build1_loc (loc, ABS_EXPR, type, arg0),
build_real (type, sqrt2_trunc));
}
@@ -8558,7 +8610,7 @@ fold_builtin_hypot (tree fndecl, tree arg0, tree arg1, tree type)
/* Fold a builtin function call to pow, powf, or powl. Return
NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
+fold_builtin_pow (location_t loc, tree fndecl, tree arg0, tree arg1, tree type)
{
tree res;
@@ -8572,7 +8624,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
/* Optimize pow(1.0,y) = 1.0. */
if (real_onep (arg0))
- return omit_one_operand (type, build_real (type, dconst1), arg1);
+ return omit_one_operand_loc (loc, type, build_real (type, dconst1), arg1);
if (TREE_CODE (arg1) == REAL_CST
&& !TREE_OVERFLOW (arg1))
@@ -8585,7 +8637,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
/* Optimize pow(x,0.0) = 1.0. */
if (REAL_VALUES_EQUAL (c, dconst0))
- return omit_one_operand (type, build_real (type, dconst1),
+ return omit_one_operand_loc (loc, type, build_real (type, dconst1),
arg0);
/* Optimize pow(x,1.0) = x. */
@@ -8594,7 +8646,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
/* Optimize pow(x,-1.0) = 1.0/x. */
if (REAL_VALUES_EQUAL (c, dconstm1))
- return fold_build2 (RDIV_EXPR, type,
+ return fold_build2_loc (loc, RDIV_EXPR, type,
build_real (type, dconst1), arg0);
/* Optimize pow(x,0.5) = sqrt(x). */
@@ -8604,7 +8656,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
tree sqrtfn = mathfn_built_in (type, BUILT_IN_SQRT);
if (sqrtfn != NULL_TREE)
- return build_call_expr (sqrtfn, 1, arg0);
+ return build_call_expr_loc (loc, sqrtfn, 1, arg0);
}
/* Optimize pow(x,1.0/3.0) = cbrt(x). */
@@ -8617,7 +8669,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
{
tree cbrtfn = mathfn_built_in (type, BUILT_IN_CBRT);
if (cbrtfn != NULL_TREE)
- return build_call_expr (cbrtfn, 1, arg0);
+ return build_call_expr_loc (loc, cbrtfn, 1, arg0);
}
}
@@ -8648,7 +8700,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
{
tree narg0 = fold_strip_sign_ops (arg0);
if (narg0)
- return build_call_expr (fndecl, 2, narg0, arg1);
+ return build_call_expr_loc (loc, fndecl, 2, narg0, arg1);
}
}
}
@@ -8662,17 +8714,17 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
{
tree expfn = TREE_OPERAND (CALL_EXPR_FN (arg0), 0);
tree arg = CALL_EXPR_ARG (arg0, 0);
- arg = fold_build2 (MULT_EXPR, type, arg, arg1);
- return build_call_expr (expfn, 1, arg);
+ arg = fold_build2_loc (loc, MULT_EXPR, type, arg, arg1);
+ return build_call_expr_loc (loc, expfn, 1, arg);
}
/* Optimize pow(sqrt(x),y) = pow(x,y*0.5). */
if (BUILTIN_SQRT_P (fcode))
{
tree narg0 = CALL_EXPR_ARG (arg0, 0);
- tree narg1 = fold_build2 (MULT_EXPR, type, arg1,
+ tree narg1 = fold_build2_loc (loc, MULT_EXPR, type, arg1,
build_real (type, dconsthalf));
- return build_call_expr (fndecl, 2, narg0, narg1);
+ return build_call_expr_loc (loc, fndecl, 2, narg0, narg1);
}
/* Optimize pow(cbrt(x),y) = pow(x,y/3) iff x is nonnegative. */
@@ -8683,9 +8735,9 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
{
const REAL_VALUE_TYPE dconstroot
= real_value_truncate (TYPE_MODE (type), dconst_third ());
- tree narg1 = fold_build2 (MULT_EXPR, type, arg1,
+ tree narg1 = fold_build2_loc (loc, MULT_EXPR, type, arg1,
build_real (type, dconstroot));
- return build_call_expr (fndecl, 2, arg, narg1);
+ return build_call_expr_loc (loc, fndecl, 2, arg, narg1);
}
}
@@ -8696,8 +8748,8 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
{
tree arg00 = CALL_EXPR_ARG (arg0, 0);
tree arg01 = CALL_EXPR_ARG (arg0, 1);
- tree narg1 = fold_build2 (MULT_EXPR, type, arg01, arg1);
- return build_call_expr (fndecl, 2, arg00, narg1);
+ tree narg1 = fold_build2_loc (loc, MULT_EXPR, type, arg01, arg1);
+ return build_call_expr_loc (loc, fndecl, 2, arg00, narg1);
}
}
@@ -8707,7 +8759,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type)
/* Fold a builtin function call to powi, powif, or powil with argument ARG.
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_powi (tree fndecl ATTRIBUTE_UNUSED,
+fold_builtin_powi (location_t loc, tree fndecl ATTRIBUTE_UNUSED,
tree arg0, tree arg1, tree type)
{
if (!validate_arg (arg0, REAL_TYPE)
@@ -8716,7 +8768,7 @@ fold_builtin_powi (tree fndecl ATTRIBUTE_UNUSED,
/* Optimize pow(1.0,y) = 1.0. */
if (real_onep (arg0))
- return omit_one_operand (type, build_real (type, dconst1), arg1);
+ return omit_one_operand_loc (loc, type, build_real (type, dconst1), arg1);
if (host_integerp (arg1, 0))
{
@@ -8734,7 +8786,7 @@ fold_builtin_powi (tree fndecl ATTRIBUTE_UNUSED,
/* Optimize pow(x,0) = 1.0. */
if (c == 0)
- return omit_one_operand (type, build_real (type, dconst1),
+ return omit_one_operand_loc (loc, type, build_real (type, dconst1),
arg0);
/* Optimize pow(x,1) = x. */
@@ -8743,7 +8795,7 @@ fold_builtin_powi (tree fndecl ATTRIBUTE_UNUSED,
/* Optimize pow(x,-1) = 1.0/x. */
if (c == -1)
- return fold_build2 (RDIV_EXPR, type,
+ return fold_build2_loc (loc, RDIV_EXPR, type,
build_real (type, dconst1), arg0);
}
@@ -8755,7 +8807,7 @@ fold_builtin_powi (tree fndecl ATTRIBUTE_UNUSED,
FUNC is the corresponding MPFR exponent function. */
static tree
-fold_builtin_exponent (tree fndecl, tree arg,
+fold_builtin_exponent (location_t loc, tree fndecl, tree arg,
int (*func)(mpfr_ptr, mpfr_srcptr, mp_rnd_t))
{
if (validate_arg (arg, REAL_TYPE))
@@ -8784,7 +8836,7 @@ fold_builtin_exponent (tree fndecl, tree arg,
&& (fcode == BUILT_IN_LOG10
|| fcode == BUILT_IN_LOG10F
|| fcode == BUILT_IN_LOG10L)))
- return fold_convert (type, CALL_EXPR_ARG (arg, 0));
+ return fold_convert_loc (loc, type, CALL_EXPR_ARG (arg, 0));
}
}
@@ -8806,7 +8858,8 @@ var_decl_component_p (tree var)
NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_memset (tree dest, tree c, tree len, tree type, bool ignore)
+fold_builtin_memset (location_t loc, tree dest, tree c, tree len,
+ tree type, bool ignore)
{
tree var, ret, etype;
unsigned HOST_WIDE_INT length, cval;
@@ -8821,7 +8874,7 @@ fold_builtin_memset (tree dest, tree c, tree len, tree type, bool ignore)
/* If the LEN parameter is zero, return DEST. */
if (integer_zerop (len))
- return omit_one_operand (type, dest, c);
+ return omit_one_operand_loc (loc, type, dest, c);
if (! host_integerp (c, 1) || TREE_SIDE_EFFECTS (dest))
return NULL_TREE;
@@ -8870,20 +8923,22 @@ fold_builtin_memset (tree dest, tree c, tree len, tree type, bool ignore)
}
ret = build_int_cst_type (etype, cval);
- var = build_fold_indirect_ref (fold_convert (build_pointer_type (etype),
- dest));
+ var = build_fold_indirect_ref_loc (loc,
+ fold_convert_loc (loc,
+ build_pointer_type (etype),
+ dest));
ret = build2 (MODIFY_EXPR, etype, var, ret);
if (ignore)
return ret;
- return omit_one_operand (type, dest, ret);
+ return omit_one_operand_loc (loc, type, dest, ret);
}
/* Fold function call to builtin memset. Return
NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_bzero (tree dest, tree size, bool ignore)
+fold_builtin_bzero (location_t loc, tree dest, tree size, bool ignore)
{
if (! validate_arg (dest, POINTER_TYPE)
|| ! validate_arg (size, INTEGER_TYPE))
@@ -8897,8 +8952,8 @@ fold_builtin_bzero (tree dest, tree size, bool ignore)
so that if it isn't expanded inline, we fallback to
calling bzero instead of memset. */
- return fold_builtin_memset (dest, integer_zero_node,
- fold_convert (sizetype, size),
+ return fold_builtin_memset (loc, dest, integer_zero_node,
+ fold_convert_loc (loc, sizetype, size),
void_type_node, ignore);
}
@@ -8911,7 +8966,8 @@ fold_builtin_bzero (tree dest, tree size, bool ignore)
(memmove). */
static tree
-fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, int endp)
+fold_builtin_memory_op (location_t loc, tree dest, tree src,
+ tree len, tree type, bool ignore, int endp)
{
tree destvar, srcvar, expr;
@@ -8922,7 +8978,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
/* If the LEN parameter is zero, return DEST. */
if (integer_zerop (len))
- return omit_one_operand (type, dest, src);
+ return omit_one_operand_loc (loc, type, dest, src);
/* If SRC and DEST are the same (and not volatile), return
DEST{,+LEN,+LEN-1}. */
@@ -8953,12 +9009,12 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
tree fn = implicit_built_in_decls[BUILT_IN_MEMCPY];
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 3, dest, src, len);
+ return build_call_expr_loc (loc, fn, 3, dest, src, len);
}
/* If *src and *dest can't overlap, optimize into memcpy as well. */
- srcvar = build_fold_indirect_ref (src);
- destvar = build_fold_indirect_ref (dest);
+ srcvar = build_fold_indirect_ref_loc (loc, src);
+ destvar = build_fold_indirect_ref_loc (loc, dest);
if (srcvar
&& !TREE_THIS_VOLATILE (srcvar)
&& destvar
@@ -9011,7 +9067,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
fn = implicit_built_in_decls[BUILT_IN_MEMCPY];
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 3, dest, src, len);
+ return build_call_expr_loc (loc, fn, 3, dest, src, len);
}
return NULL_TREE;
}
@@ -9078,7 +9134,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
srcvar = NULL_TREE;
if (tree_int_cst_equal (TYPE_SIZE_UNIT (srctype), len))
{
- srcvar = build_fold_indirect_ref (src);
+ srcvar = build_fold_indirect_ref_loc (loc, src);
if (TREE_THIS_VOLATILE (srcvar))
return NULL_TREE;
else if (!tree_int_cst_equal (lang_hooks.expr_size (srcvar), len))
@@ -9096,7 +9152,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
destvar = NULL_TREE;
if (tree_int_cst_equal (TYPE_SIZE_UNIT (desttype), len))
{
- destvar = build_fold_indirect_ref (dest);
+ destvar = build_fold_indirect_ref_loc (loc, dest);
if (TREE_THIS_VOLATILE (destvar))
return NULL_TREE;
else if (!tree_int_cst_equal (lang_hooks.expr_size (destvar), len))
@@ -9127,8 +9183,8 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
TYPE_PACKED (srctype) = 1;
}
srcptype = build_pointer_type_for_mode (srctype, ptr_mode, true);
- src = fold_convert (srcptype, src);
- srcvar = build_fold_indirect_ref (src);
+ src = fold_convert_loc (loc, srcptype, src);
+ srcvar = build_fold_indirect_ref_loc (loc, src);
}
else if (destvar == NULL_TREE)
{
@@ -9149,8 +9205,8 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
TYPE_PACKED (desttype) = 1;
}
destptype = build_pointer_type_for_mode (desttype, ptr_mode, true);
- dest = fold_convert (destptype, dest);
- destvar = build_fold_indirect_ref (dest);
+ dest = fold_convert_loc (loc, destptype, dest);
+ destvar = build_fold_indirect_ref_loc (loc, dest);
}
if (srctype == desttype
@@ -9161,9 +9217,10 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
|| POINTER_TYPE_P (TREE_TYPE (srcvar)))
&& (INTEGRAL_TYPE_P (TREE_TYPE (destvar))
|| POINTER_TYPE_P (TREE_TYPE (destvar))))
- expr = fold_convert (TREE_TYPE (destvar), srcvar);
+ expr = fold_convert_loc (loc, TREE_TYPE (destvar), srcvar);
else
- expr = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (destvar), srcvar);
+ expr = fold_build1_loc (loc, VIEW_CONVERT_EXPR,
+ TREE_TYPE (destvar), srcvar);
expr = build2 (MODIFY_EXPR, TREE_TYPE (destvar), destvar, expr);
}
@@ -9171,20 +9228,20 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
return expr;
if (endp == 0 || endp == 3)
- return omit_one_operand (type, dest, expr);
+ return omit_one_operand_loc (loc, type, dest, expr);
if (expr == len)
expr = NULL_TREE;
if (endp == 2)
- len = fold_build2 (MINUS_EXPR, TREE_TYPE (len), len,
+ len = fold_build2_loc (loc, MINUS_EXPR, TREE_TYPE (len), len,
ssize_int (1));
- len = fold_convert (sizetype, len);
- dest = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dest), dest, len);
- dest = fold_convert (type, dest);
+ len = fold_convert_loc (loc, sizetype, len);
+ dest = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (dest), dest, len);
+ dest = fold_convert_loc (loc, type, dest);
if (expr)
- dest = omit_one_operand (type, dest, expr);
+ dest = omit_one_operand_loc (loc, type, dest, expr);
return dest;
}
@@ -9193,7 +9250,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
copied. Return NULL_TREE if no simplification can be made. */
tree
-fold_builtin_strcpy (tree fndecl, tree dest, tree src, tree len)
+fold_builtin_strcpy (location_t loc, tree fndecl, tree dest, tree src, tree len)
{
tree fn;
@@ -9203,7 +9260,7 @@ fold_builtin_strcpy (tree fndecl, tree dest, tree src, tree len)
/* If SRC and DEST are the same (and not volatile), return DEST. */
if (operand_equal_p (src, dest, 0))
- return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), dest);
+ return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest);
if (optimize_function_for_size_p (cfun))
return NULL_TREE;
@@ -9219,9 +9276,9 @@ fold_builtin_strcpy (tree fndecl, tree dest, tree src, tree len)
return NULL_TREE;
}
- len = size_binop (PLUS_EXPR, len, ssize_int (1));
- return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)),
- build_call_expr (fn, 3, dest, src, len));
+ len = size_binop_loc (loc, PLUS_EXPR, len, ssize_int (1));
+ return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)),
+ build_call_expr_loc (loc, fn, 3, dest, src, len));
}
/* Fold function call to builtin strncpy with arguments DEST, SRC, and LEN.
@@ -9229,7 +9286,8 @@ fold_builtin_strcpy (tree fndecl, tree dest, tree src, tree len)
Return NULL_TREE if no simplification can be made. */
tree
-fold_builtin_strncpy (tree fndecl, tree dest, tree src, tree len, tree slen)
+fold_builtin_strncpy (location_t loc, tree fndecl, tree dest,
+ tree src, tree len, tree slen)
{
tree fn;
@@ -9240,7 +9298,7 @@ fold_builtin_strncpy (tree fndecl, tree dest, tree src, tree len, tree slen)
/* If the LEN parameter is zero, return DEST. */
if (integer_zerop (len))
- return omit_one_operand (TREE_TYPE (TREE_TYPE (fndecl)), dest, src);
+ return omit_one_operand_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest, src);
/* We can't compare slen with len as constants below if len is not a
constant. */
@@ -9254,7 +9312,7 @@ fold_builtin_strncpy (tree fndecl, tree dest, tree src, tree len, tree slen)
if (slen == 0 || TREE_CODE (slen) != INTEGER_CST)
return NULL_TREE;
- slen = size_binop (PLUS_EXPR, slen, ssize_int (1));
+ slen = size_binop_loc (loc, PLUS_EXPR, slen, ssize_int (1));
/* We do not support simplification of this case, though we do
support it when expanding trees into RTL. */
@@ -9266,8 +9324,8 @@ fold_builtin_strncpy (tree fndecl, tree dest, tree src, tree len, tree slen)
fn = implicit_built_in_decls[BUILT_IN_MEMCPY];
if (!fn)
return NULL_TREE;
- return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)),
- build_call_expr (fn, 3, dest, src, len));
+ return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)),
+ build_call_expr_loc (loc, fn, 3, dest, src, len));
}
/* Fold function call to builtin memchr. ARG1, ARG2 and LEN are the
@@ -9275,7 +9333,7 @@ fold_builtin_strncpy (tree fndecl, tree dest, tree src, tree len, tree slen)
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_memchr (tree arg1, tree arg2, tree len, tree type)
+fold_builtin_memchr (location_t loc, tree arg1, tree arg2, tree len, tree type)
{
if (!validate_arg (arg1, POINTER_TYPE)
|| !validate_arg (arg2, INTEGER_TYPE)
@@ -9304,9 +9362,9 @@ fold_builtin_memchr (tree arg1, tree arg2, tree len, tree type)
if (r == NULL)
return build_int_cst (TREE_TYPE (arg1), 0);
- tem = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (arg1), arg1,
+ tem = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (arg1), arg1,
size_int (r - p1));
- return fold_convert (type, tem);
+ return fold_convert_loc (loc, type, tem);
}
return NULL_TREE;
}
@@ -9316,7 +9374,7 @@ fold_builtin_memchr (tree arg1, tree arg2, tree len, tree type)
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_memcmp (tree arg1, tree arg2, tree len)
+fold_builtin_memcmp (location_t loc, tree arg1, tree arg2, tree len)
{
const char *p1, *p2;
@@ -9327,12 +9385,12 @@ fold_builtin_memcmp (tree arg1, tree arg2, tree len)
/* If the LEN parameter is zero, return zero. */
if (integer_zerop (len))
- return omit_two_operands (integer_type_node, integer_zero_node,
+ return omit_two_operands_loc (loc, integer_type_node, integer_zero_node,
arg1, arg2);
/* If ARG1 and ARG2 are the same (and not volatile), return zero. */
if (operand_equal_p (arg1, arg2, 0))
- return omit_one_operand (integer_type_node, integer_zero_node, len);
+ return omit_one_operand_loc (loc, integer_type_node, integer_zero_node, len);
p1 = c_getstr (arg1);
p2 = c_getstr (arg2);
@@ -9361,15 +9419,19 @@ fold_builtin_memcmp (tree arg1, tree arg2, tree len)
tree cst_uchar_ptr_node
= build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true);
- tree ind1 = fold_convert (integer_type_node,
- build1 (INDIRECT_REF, cst_uchar_node,
- fold_convert (cst_uchar_ptr_node,
+ tree ind1
+ = fold_convert_loc (loc, integer_type_node,
+ build1 (INDIRECT_REF, cst_uchar_node,
+ fold_convert_loc (loc,
+ cst_uchar_ptr_node,
arg1)));
- tree ind2 = fold_convert (integer_type_node,
- build1 (INDIRECT_REF, cst_uchar_node,
- fold_convert (cst_uchar_ptr_node,
+ tree ind2
+ = fold_convert_loc (loc, integer_type_node,
+ build1 (INDIRECT_REF, cst_uchar_node,
+ fold_convert_loc (loc,
+ cst_uchar_ptr_node,
arg2)));
- return fold_build2 (MINUS_EXPR, integer_type_node, ind1, ind2);
+ return fold_build2_loc (loc, MINUS_EXPR, integer_type_node, ind1, ind2);
}
return NULL_TREE;
@@ -9379,7 +9441,7 @@ fold_builtin_memcmp (tree arg1, tree arg2, tree len)
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_strcmp (tree arg1, tree arg2)
+fold_builtin_strcmp (location_t loc, tree arg1, tree arg2)
{
const char *p1, *p2;
@@ -9412,10 +9474,11 @@ fold_builtin_strcmp (tree arg1, tree arg2)
tree cst_uchar_ptr_node
= build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true);
- return fold_convert (integer_type_node,
- build1 (INDIRECT_REF, cst_uchar_node,
- fold_convert (cst_uchar_ptr_node,
- arg1)));
+ return fold_convert_loc (loc, integer_type_node,
+ build1 (INDIRECT_REF, cst_uchar_node,
+ fold_convert_loc (loc,
+ cst_uchar_ptr_node,
+ arg1)));
}
/* If the first arg is "", return -*(const unsigned char*)arg2. */
@@ -9425,11 +9488,13 @@ fold_builtin_strcmp (tree arg1, tree arg2)
tree cst_uchar_ptr_node
= build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true);
- tree temp = fold_convert (integer_type_node,
- build1 (INDIRECT_REF, cst_uchar_node,
- fold_convert (cst_uchar_ptr_node,
+ tree temp
+ = fold_convert_loc (loc, integer_type_node,
+ build1 (INDIRECT_REF, cst_uchar_node,
+ fold_convert_loc (loc,
+ cst_uchar_ptr_node,
arg2)));
- return fold_build1 (NEGATE_EXPR, integer_type_node, temp);
+ return fold_build1_loc (loc, NEGATE_EXPR, integer_type_node, temp);
}
return NULL_TREE;
@@ -9439,7 +9504,7 @@ fold_builtin_strcmp (tree arg1, tree arg2)
Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_strncmp (tree arg1, tree arg2, tree len)
+fold_builtin_strncmp (location_t loc, tree arg1, tree arg2, tree len)
{
const char *p1, *p2;
@@ -9450,12 +9515,12 @@ fold_builtin_strncmp (tree arg1, tree arg2, tree len)
/* If the LEN parameter is zero, return zero. */
if (integer_zerop (len))
- return omit_two_operands (integer_type_node, integer_zero_node,
+ return omit_two_operands_loc (loc, integer_type_node, integer_zero_node,
arg1, arg2);
/* If ARG1 and ARG2 are the same (and not volatile), return zero. */
if (operand_equal_p (arg1, arg2, 0))
- return omit_one_operand (integer_type_node, integer_zero_node, len);
+ return omit_one_operand_loc (loc, integer_type_node, integer_zero_node, len);
p1 = c_getstr (arg1);
p2 = c_getstr (arg2);
@@ -9481,10 +9546,11 @@ fold_builtin_strncmp (tree arg1, tree arg2, tree len)
tree cst_uchar_ptr_node
= build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true);
- return fold_convert (integer_type_node,
- build1 (INDIRECT_REF, cst_uchar_node,
- fold_convert (cst_uchar_ptr_node,
- arg1)));
+ return fold_convert_loc (loc, integer_type_node,
+ build1 (INDIRECT_REF, cst_uchar_node,
+ fold_convert_loc (loc,
+ cst_uchar_ptr_node,
+ arg1)));
}
/* If the first arg is "", and the length is greater than zero,
@@ -9497,11 +9563,12 @@ fold_builtin_strncmp (tree arg1, tree arg2, tree len)
tree cst_uchar_ptr_node
= build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true);
- tree temp = fold_convert (integer_type_node,
- build1 (INDIRECT_REF, cst_uchar_node,
- fold_convert (cst_uchar_ptr_node,
- arg2)));
- return fold_build1 (NEGATE_EXPR, integer_type_node, temp);
+ tree temp = fold_convert_loc (loc, integer_type_node,
+ build1 (INDIRECT_REF, cst_uchar_node,
+ fold_convert_loc (loc,
+ cst_uchar_ptr_node,
+ arg2)));
+ return fold_build1_loc (loc, NEGATE_EXPR, integer_type_node, temp);
}
/* If len parameter is one, return an expression corresponding to
@@ -9512,15 +9579,17 @@ fold_builtin_strncmp (tree arg1, tree arg2, tree len)
tree cst_uchar_ptr_node
= build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true);
- tree ind1 = fold_convert (integer_type_node,
- build1 (INDIRECT_REF, cst_uchar_node,
- fold_convert (cst_uchar_ptr_node,
- arg1)));
- tree ind2 = fold_convert (integer_type_node,
- build1 (INDIRECT_REF, cst_uchar_node,
- fold_convert (cst_uchar_ptr_node,
- arg2)));
- return fold_build2 (MINUS_EXPR, integer_type_node, ind1, ind2);
+ tree ind1 = fold_convert_loc (loc, integer_type_node,
+ build1 (INDIRECT_REF, cst_uchar_node,
+ fold_convert_loc (loc,
+ cst_uchar_ptr_node,
+ arg1)));
+ tree ind2 = fold_convert_loc (loc, integer_type_node,
+ build1 (INDIRECT_REF, cst_uchar_node,
+ fold_convert_loc (loc,
+ cst_uchar_ptr_node,
+ arg2)));
+ return fold_build2_loc (loc, MINUS_EXPR, integer_type_node, ind1, ind2);
}
return NULL_TREE;
@@ -9530,7 +9599,7 @@ fold_builtin_strncmp (tree arg1, tree arg2, tree len)
ARG. Return NULL_TREE if no simplification can be made. */
static tree
-fold_builtin_signbit (tree arg, tree type)
+fold_builtin_signbit (location_t loc, tree arg, tree type)
{
tree temp;
@@ -9545,16 +9614,16 @@ fold_builtin_signbit (tree arg, tree type)
c = TREE_REAL_CST (arg);
temp = REAL_VALUE_NEGATIVE (c) ? integer_one_node : integer_zero_node;
- return fold_convert (type, temp);
+ return fold_convert_loc (loc, type, temp);
}
/* If ARG is non-negative, the result is always zero. */
if (tree_expr_nonnegative_p (arg))
- return omit_one_operand (type, integer_zero_node, arg);
+ return omit_one_operand_loc (loc, type, integer_zero_node, arg);
/* If ARG's format doesn't have signed zeros, return "arg < 0.0". */
if (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg))))
- return fold_build2 (LT_EXPR, type, arg,
+ return fold_build2_loc (loc, LT_EXPR, type, arg,
build_real (TREE_TYPE (arg), dconst0));
return NULL_TREE;
@@ -9565,7 +9634,8 @@ fold_builtin_signbit (tree arg, tree type)
be made. */
static tree
-fold_builtin_copysign (tree fndecl, tree arg1, tree arg2, tree type)
+fold_builtin_copysign (location_t loc, tree fndecl,
+ tree arg1, tree arg2, tree type)
{
tree tem;
@@ -9575,7 +9645,7 @@ fold_builtin_copysign (tree fndecl, tree arg1, tree arg2, tree type)
/* copysign(X,X) is X. */
if (operand_equal_p (arg1, arg2, 0))
- return fold_convert (type, arg1);
+ return fold_convert_loc (loc, type, arg1);
/* If ARG1 and ARG2 are compile-time constants, determine the result. */
if (TREE_CODE (arg1) == REAL_CST
@@ -9595,14 +9665,14 @@ fold_builtin_copysign (tree fndecl, tree arg1, tree arg2, tree type)
/* copysign(X, Y) is fabs(X) when Y is always non-negative.
Remember to evaluate Y for side-effects. */
if (tree_expr_nonnegative_p (arg2))
- return omit_one_operand (type,
- fold_build1 (ABS_EXPR, type, arg1),
+ return omit_one_operand_loc (loc, type,
+ fold_build1_loc (loc, ABS_EXPR, type, arg1),
arg2);
/* Strip sign changing operations for the first argument. */
tem = fold_strip_sign_ops (arg1);
if (tem)
- return build_call_expr (fndecl, 2, tem, arg2);
+ return build_call_expr_loc (loc, fndecl, 2, tem, arg2);
return NULL_TREE;
}
@@ -9610,7 +9680,7 @@ fold_builtin_copysign (tree fndecl, tree arg1, tree arg2, tree type)
/* Fold a call to builtin isascii with argument ARG. */
static tree
-fold_builtin_isascii (tree arg)
+fold_builtin_isascii (location_t loc, tree arg)
{
if (!validate_arg (arg, INTEGER_TYPE))
return NULL_TREE;
@@ -9620,7 +9690,7 @@ fold_builtin_isascii (tree arg)
arg = build2 (BIT_AND_EXPR, integer_type_node, arg,
build_int_cst (NULL_TREE,
~ (unsigned HOST_WIDE_INT) 0x7f));
- return fold_build2 (EQ_EXPR, integer_type_node,
+ return fold_build2_loc (loc, EQ_EXPR, integer_type_node,
arg, integer_zero_node);
}
}
@@ -9628,20 +9698,20 @@ fold_builtin_isascii (tree arg)
/* Fold a call to builtin toascii with argument ARG. */
static tree
-fold_builtin_toascii (tree arg)
+fold_builtin_toascii (location_t loc, tree arg)
{
if (!validate_arg (arg, INTEGER_TYPE))
return NULL_TREE;
/* Transform toascii(c) -> (c & 0x7f). */
- return fold_build2 (BIT_AND_EXPR, integer_type_node, arg,
+ return fold_build2_loc (loc, BIT_AND_EXPR, integer_type_node, arg,
build_int_cst (NULL_TREE, 0x7f));
}
/* Fold a call to builtin isdigit with argument ARG. */
static tree
-fold_builtin_isdigit (tree arg)
+fold_builtin_isdigit (location_t loc, tree arg)
{
if (!validate_arg (arg, INTEGER_TYPE))
return NULL_TREE;
@@ -9656,10 +9726,10 @@ fold_builtin_isdigit (tree arg)
if (target_digit0 == 0)
return NULL_TREE;
- arg = fold_convert (unsigned_type_node, arg);
+ arg = fold_convert_loc (loc, unsigned_type_node, arg);
arg = build2 (MINUS_EXPR, unsigned_type_node, arg,
build_int_cst (unsigned_type_node, target_digit0));
- return fold_build2 (LE_EXPR, integer_type_node, arg,
+ return fold_build2_loc (loc, LE_EXPR, integer_type_node, arg,
build_int_cst (unsigned_type_node, 9));
}
}
@@ -9667,35 +9737,36 @@ fold_builtin_isdigit (tree arg)
/* Fold a call to fabs, fabsf or fabsl with argument ARG. */
static tree
-fold_builtin_fabs (tree arg, tree type)
+fold_builtin_fabs (location_t loc, tree arg, tree type)
{
if (!validate_arg (arg, REAL_TYPE))
return NULL_TREE;
- arg = fold_convert (type, arg);
+ arg = fold_convert_loc (loc, type, arg);
if (TREE_CODE (arg) == REAL_CST)
return fold_abs_const (arg, type);
- return fold_build1 (ABS_EXPR, type, arg);
+ return fold_build1_loc (loc, ABS_EXPR, type, arg);
}
/* Fold a call to abs, labs, llabs or imaxabs with argument ARG. */
static tree
-fold_builtin_abs (tree arg, tree type)
+fold_builtin_abs (location_t loc, tree arg, tree type)
{
if (!validate_arg (arg, INTEGER_TYPE))
return NULL_TREE;
- arg = fold_convert (type, arg);
+ arg = fold_convert_loc (loc, type, arg);
if (TREE_CODE (arg) == INTEGER_CST)
return fold_abs_const (arg, type);
- return fold_build1 (ABS_EXPR, type, arg);
+ return fold_build1_loc (loc, ABS_EXPR, type, arg);
}
/* Fold a call to builtin fmin or fmax. */
static tree
-fold_builtin_fmin_fmax (tree arg0, tree arg1, tree type, bool max)
+fold_builtin_fmin_fmax (location_t loc, tree arg0, tree arg1,
+ tree type, bool max)
{
if (validate_arg (arg0, REAL_TYPE) && validate_arg (arg1, REAL_TYPE))
{
@@ -9712,16 +9783,16 @@ fold_builtin_fmin_fmax (tree arg0, tree arg1, tree type, bool max)
&& real_isnan (&TREE_REAL_CST (arg0))
&& (! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0)))
|| ! TREE_REAL_CST (arg0).signalling))
- return omit_one_operand (type, arg1, arg0);
+ return omit_one_operand_loc (loc, type, arg1, arg0);
if (TREE_CODE (arg1) == REAL_CST
&& real_isnan (&TREE_REAL_CST (arg1))
&& (! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg1)))
|| ! TREE_REAL_CST (arg1).signalling))
- return omit_one_operand (type, arg0, arg1);
+ return omit_one_operand_loc (loc, type, arg0, arg1);
/* Transform fmin/fmax(x,x) -> x. */
if (operand_equal_p (arg0, arg1, OEP_PURE_SAME))
- return omit_one_operand (type, arg0, arg1);
+ return omit_one_operand_loc (loc, type, arg0, arg1);
/* Convert fmin/fmax to MIN_EXPR/MAX_EXPR. C99 requires these
functions to return the numeric arg if the other one is NaN.
@@ -9729,9 +9800,9 @@ fold_builtin_fmin_fmax (tree arg0, tree arg1, tree type, bool max)
-ffinite-math-only is set. C99 doesn't require -0.0 to be
handled, so we don't have to worry about it either. */
if (flag_finite_math_only)
- return fold_build2 ((max ? MAX_EXPR : MIN_EXPR), type,
- fold_convert (type, arg0),
- fold_convert (type, arg1));
+ return fold_build2_loc (loc, (max ? MAX_EXPR : MIN_EXPR), type,
+ fold_convert_loc (loc, type, arg0),
+ fold_convert_loc (loc, type, arg1));
}
return NULL_TREE;
}
@@ -9739,7 +9810,7 @@ fold_builtin_fmin_fmax (tree arg0, tree arg1, tree type, bool max)
/* Fold a call to builtin carg(a+bi) -> atan2(b,a). */
static tree
-fold_builtin_carg (tree arg, tree type)
+fold_builtin_carg (location_t loc, tree arg, tree type)
{
if (validate_arg (arg, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg))) == REAL_TYPE)
@@ -9749,9 +9820,9 @@ fold_builtin_carg (tree arg, tree type)
if (atan2_fn)
{
tree new_arg = builtin_save_expr (arg);
- tree r_arg = fold_build1 (REALPART_EXPR, type, new_arg);
- tree i_arg = fold_build1 (IMAGPART_EXPR, type, new_arg);
- return build_call_expr (atan2_fn, 2, i_arg, r_arg);
+ tree r_arg = fold_build1_loc (loc, REALPART_EXPR, type, new_arg);
+ tree i_arg = fold_build1_loc (loc, IMAGPART_EXPR, type, new_arg);
+ return build_call_expr_loc (loc, atan2_fn, 2, i_arg, r_arg);
}
}
@@ -9761,7 +9832,7 @@ fold_builtin_carg (tree arg, tree type)
/* Fold a call to builtin logb/ilogb. */
static tree
-fold_builtin_logb (tree arg, tree rettype)
+fold_builtin_logb (location_t loc, tree arg, tree rettype)
{
if (! validate_arg (arg, REAL_TYPE))
return NULL_TREE;
@@ -9778,7 +9849,7 @@ fold_builtin_logb (tree arg, tree rettype)
case rvc_inf:
/* If arg is Inf or NaN and we're logb, return it. */
if (TREE_CODE (rettype) == REAL_TYPE)
- return fold_convert (rettype, arg);
+ return fold_convert_loc (loc, rettype, arg);
/* Fall through... */
case rvc_zero:
/* Zero may set errno and/or raise an exception for logb, also
@@ -9790,8 +9861,9 @@ fold_builtin_logb (tree arg, tree rettype)
want the exponent as if they were [1.0, 2.0) so get the
exponent and subtract 1. */
if (REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (arg)))->b == 2)
- return fold_convert (rettype, build_int_cst (NULL_TREE,
- REAL_EXP (value)-1));
+ return fold_convert_loc (loc, rettype,
+ build_int_cst (NULL_TREE,
+ REAL_EXP (value)-1));
break;
}
}
@@ -9802,7 +9874,7 @@ fold_builtin_logb (tree arg, tree rettype)
/* Fold a call to builtin significand, if radix == 2. */
static tree
-fold_builtin_significand (tree arg, tree rettype)
+fold_builtin_significand (location_t loc, tree arg, tree rettype)
{
if (! validate_arg (arg, REAL_TYPE))
return NULL_TREE;
@@ -9819,7 +9891,7 @@ fold_builtin_significand (tree arg, tree rettype)
case rvc_nan:
case rvc_inf:
/* If arg is +-0, +-Inf or +-NaN, then return it. */
- return fold_convert (rettype, arg);
+ return fold_convert_loc (loc, rettype, arg);
case rvc_normal:
/* For normal numbers, proceed iff radix == 2. */
if (REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (arg)))->b == 2)
@@ -9841,7 +9913,7 @@ fold_builtin_significand (tree arg, tree rettype)
/* Fold a call to builtin frexp, we can assume the base is 2. */
static tree
-fold_builtin_frexp (tree arg0, tree arg1, tree rettype)
+fold_builtin_frexp (location_t loc, tree arg0, tree arg1, tree rettype)
{
if (! validate_arg (arg0, REAL_TYPE) || ! validate_arg (arg1, POINTER_TYPE))
return NULL_TREE;
@@ -9851,7 +9923,7 @@ fold_builtin_frexp (tree arg0, tree arg1, tree rettype)
if (!(TREE_CODE (arg0) == REAL_CST && ! TREE_OVERFLOW (arg0)))
return NULL_TREE;
- arg1 = build_fold_indirect_ref (arg1);
+ arg1 = build_fold_indirect_ref_loc (loc, arg1);
/* Proceed if a valid pointer type was passed in. */
if (TYPE_MAIN_VARIANT (TREE_TYPE (arg1)) == integer_type_node)
@@ -9869,7 +9941,7 @@ fold_builtin_frexp (tree arg0, tree arg1, tree rettype)
case rvc_nan:
case rvc_inf:
/* For +-NaN or +-Inf, *exp is unspecified, return arg0. */
- return omit_one_operand (rettype, arg0, arg1);
+ return omit_one_operand_loc (loc, rettype, arg0, arg1);
case rvc_normal:
{
/* Since the frexp function always expects base 2, and in
@@ -9886,9 +9958,9 @@ fold_builtin_frexp (tree arg0, tree arg1, tree rettype)
}
/* Create the COMPOUND_EXPR (*arg1 = trunc, frac). */
- arg1 = fold_build2 (MODIFY_EXPR, rettype, arg1, exp);
+ arg1 = fold_build2_loc (loc, MODIFY_EXPR, rettype, arg1, exp);
TREE_SIDE_EFFECTS (arg1) = 1;
- return fold_build2 (COMPOUND_EXPR, rettype, arg1, frac);
+ return fold_build2_loc (loc, COMPOUND_EXPR, rettype, arg1, frac);
}
return NULL_TREE;
@@ -9899,7 +9971,8 @@ fold_builtin_frexp (tree arg0, tree arg1, tree rettype)
check the mode of the TYPE parameter in certain cases. */
static tree
-fold_builtin_load_exponent (tree arg0, tree arg1, tree type, bool ldexp)
+fold_builtin_load_exponent (location_t loc, tree arg0, tree arg1,
+ tree type, bool ldexp)
{
if (validate_arg (arg0, REAL_TYPE) && validate_arg (arg1, INTEGER_TYPE))
{
@@ -9910,7 +9983,7 @@ fold_builtin_load_exponent (tree arg0, tree arg1, tree type, bool ldexp)
if (real_zerop (arg0) || integer_zerop (arg1)
|| (TREE_CODE (arg0) == REAL_CST
&& !real_isfinite (&TREE_REAL_CST (arg0))))
- return omit_one_operand (type, arg0, arg1);
+ return omit_one_operand_loc (loc, type, arg0, arg1);
/* If both arguments are constant, then try to evaluate it. */
if ((ldexp || REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2)
@@ -9957,7 +10030,7 @@ fold_builtin_load_exponent (tree arg0, tree arg1, tree type, bool ldexp)
/* Fold a call to builtin modf. */
static tree
-fold_builtin_modf (tree arg0, tree arg1, tree rettype)
+fold_builtin_modf (location_t loc, tree arg0, tree arg1, tree rettype)
{
if (! validate_arg (arg0, REAL_TYPE) || ! validate_arg (arg1, POINTER_TYPE))
return NULL_TREE;
@@ -9967,7 +10040,7 @@ fold_builtin_modf (tree arg0, tree arg1, tree rettype)
if (!(TREE_CODE (arg0) == REAL_CST && ! TREE_OVERFLOW (arg0)))
return NULL_TREE;
- arg1 = build_fold_indirect_ref (arg1);
+ arg1 = build_fold_indirect_ref_loc (loc, arg1);
/* Proceed if a valid pointer type was passed in. */
if (TYPE_MAIN_VARIANT (TREE_TYPE (arg1)) == TYPE_MAIN_VARIANT (rettype))
@@ -10000,10 +10073,10 @@ fold_builtin_modf (tree arg0, tree arg1, tree rettype)
}
/* Create the COMPOUND_EXPR (*arg1 = trunc, frac). */
- arg1 = fold_build2 (MODIFY_EXPR, rettype, arg1,
+ arg1 = fold_build2_loc (loc, MODIFY_EXPR, rettype, arg1,
build_real (rettype, trunc));
TREE_SIDE_EFFECTS (arg1) = 1;
- return fold_build2 (COMPOUND_EXPR, rettype, arg1,
+ return fold_build2_loc (loc, COMPOUND_EXPR, rettype, arg1,
build_real (rettype, frac));
}
@@ -10014,7 +10087,7 @@ fold_builtin_modf (tree arg0, tree arg1, tree rettype)
ARG is the argument for the call. */
static tree
-fold_builtin_classify (tree fndecl, tree arg, int builtin_index)
+fold_builtin_classify (location_t loc, tree fndecl, tree arg, int builtin_index)
{
tree type = TREE_TYPE (TREE_TYPE (fndecl));
REAL_VALUE_TYPE r;
@@ -10026,7 +10099,7 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index)
{
case BUILT_IN_ISINF:
if (!HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
- return omit_one_operand (type, integer_zero_node, arg);
+ return omit_one_operand_loc (loc, type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
{
@@ -10054,17 +10127,18 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index)
if (signbit_fn && isinf_fn)
{
- tree signbit_call = build_call_expr (signbit_fn, 1, arg);
- tree isinf_call = build_call_expr (isinf_fn, 1, arg);
+ tree signbit_call = build_call_expr_loc (loc, signbit_fn, 1, arg);
+ tree isinf_call = build_call_expr_loc (loc, isinf_fn, 1, arg);
- signbit_call = fold_build2 (NE_EXPR, integer_type_node,
+ signbit_call = fold_build2_loc (loc, NE_EXPR, integer_type_node,
signbit_call, integer_zero_node);
- isinf_call = fold_build2 (NE_EXPR, integer_type_node,
+ isinf_call = fold_build2_loc (loc, NE_EXPR, integer_type_node,
isinf_call, integer_zero_node);
- tmp = fold_build3 (COND_EXPR, integer_type_node, signbit_call,
+ tmp = fold_build3_loc (loc, COND_EXPR, integer_type_node, signbit_call,
integer_minus_one_node, integer_one_node);
- tmp = fold_build3 (COND_EXPR, integer_type_node, isinf_call, tmp,
+ tmp = fold_build3_loc (loc, COND_EXPR, integer_type_node,
+ isinf_call, tmp,
integer_zero_node);
}
@@ -10074,7 +10148,7 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index)
case BUILT_IN_ISFINITE:
if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg)))
&& !HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
- return omit_one_operand (type, integer_one_node, arg);
+ return omit_one_operand_loc (loc, type, integer_one_node, arg);
if (TREE_CODE (arg) == REAL_CST)
{
@@ -10086,7 +10160,7 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index)
case BUILT_IN_ISNAN:
if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg))))
- return omit_one_operand (type, integer_zero_node, arg);
+ return omit_one_operand_loc (loc, type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
{
@@ -10095,7 +10169,7 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index)
}
arg = builtin_save_expr (arg);
- return fold_build2 (UNORDERED_EXPR, type, arg, arg);
+ return fold_build2_loc (loc, UNORDERED_EXPR, type, arg, arg);
default:
gcc_unreachable ();
@@ -10111,7 +10185,7 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index)
one floating point argument which is "type generic". */
static tree
-fold_builtin_fpclassify (tree exp)
+fold_builtin_fpclassify (location_t loc, tree exp)
{
tree fp_nan, fp_infinite, fp_normal, fp_subnormal, fp_zero,
arg, type, res, tmp;
@@ -10133,7 +10207,7 @@ fold_builtin_fpclassify (tree exp)
arg = CALL_EXPR_ARG (exp, 5);
type = TREE_TYPE (arg);
mode = TYPE_MODE (type);
- arg = builtin_save_expr (fold_build1 (ABS_EXPR, type, arg));
+ arg = builtin_save_expr (fold_build1_loc (loc, ABS_EXPR, type, arg));
/* fpclassify(x) ->
isnan(x) ? FP_NAN :
@@ -10141,27 +10215,30 @@ fold_builtin_fpclassify (tree exp)
(fabs(x) >= DBL_MIN ? FP_NORMAL :
(x == 0 ? FP_ZERO : FP_SUBNORMAL))). */
- tmp = fold_build2 (EQ_EXPR, integer_type_node, arg,
+ tmp = fold_build2_loc (loc, EQ_EXPR, integer_type_node, arg,
build_real (type, dconst0));
- res = fold_build3 (COND_EXPR, integer_type_node, tmp, fp_zero, fp_subnormal);
+ res = fold_build3_loc (loc, COND_EXPR, integer_type_node,
+ tmp, fp_zero, fp_subnormal);
sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (mode)->emin - 1);
real_from_string (&r, buf);
- tmp = fold_build2 (GE_EXPR, integer_type_node, arg, build_real (type, r));
- res = fold_build3 (COND_EXPR, integer_type_node, tmp, fp_normal, res);
+ tmp = fold_build2_loc (loc, GE_EXPR, integer_type_node,
+ arg, build_real (type, r));
+ res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp, fp_normal, res);
if (HONOR_INFINITIES (mode))
{
real_inf (&r);
- tmp = fold_build2 (EQ_EXPR, integer_type_node, arg,
+ tmp = fold_build2_loc (loc, EQ_EXPR, integer_type_node, arg,
build_real (type, r));
- res = fold_build3 (COND_EXPR, integer_type_node, tmp, fp_infinite, res);
+ res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp,
+ fp_infinite, res);
}
if (HONOR_NANS (mode))
{
- tmp = fold_build2 (ORDERED_EXPR, integer_type_node, arg, arg);
- res = fold_build3 (COND_EXPR, integer_type_node, tmp, res, fp_nan);
+ tmp = fold_build2_loc (loc, ORDERED_EXPR, integer_type_node, arg, arg);
+ res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp, res, fp_nan);
}
return res;
@@ -10176,7 +10253,7 @@ fold_builtin_fpclassify (tree exp)
the rest. */
static tree
-fold_builtin_unordered_cmp (tree fndecl, tree arg0, tree arg1,
+fold_builtin_unordered_cmp (location_t loc, tree fndecl, tree arg0, tree arg1,
enum tree_code unordered_code,
enum tree_code ordered_code)
{
@@ -10201,20 +10278,20 @@ fold_builtin_unordered_cmp (tree fndecl, tree arg0, tree arg1,
else if (code0 == INTEGER_TYPE && code1 == REAL_TYPE)
cmp_type = type1;
- arg0 = fold_convert (cmp_type, arg0);
- arg1 = fold_convert (cmp_type, arg1);
+ arg0 = fold_convert_loc (loc, cmp_type, arg0);
+ arg1 = fold_convert_loc (loc, cmp_type, arg1);
if (unordered_code == UNORDERED_EXPR)
{
if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))))
- return omit_two_operands (type, integer_zero_node, arg0, arg1);
- return fold_build2 (UNORDERED_EXPR, type, arg0, arg1);
+ return omit_two_operands_loc (loc, type, integer_zero_node, arg0, arg1);
+ return fold_build2_loc (loc, UNORDERED_EXPR, type, arg0, arg1);
}
code = HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code
: ordered_code;
- return fold_build1 (TRUTH_NOT_EXPR, type,
- fold_build2 (code, type, arg0, arg1));
+ return fold_build1_loc (loc, TRUTH_NOT_EXPR, type,
+ fold_build2_loc (loc, code, type, arg0, arg1));
}
/* Fold a call to built-in function FNDECL with 0 arguments.
@@ -10222,7 +10299,7 @@ fold_builtin_unordered_cmp (tree fndecl, tree arg0, tree arg1,
function returns NULL_TREE if no simplification was possible. */
static tree
-fold_builtin_0 (tree fndecl, bool ignore ATTRIBUTE_UNUSED)
+fold_builtin_0 (location_t loc, tree fndecl, bool ignore ATTRIBUTE_UNUSED)
{
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
@@ -10232,10 +10309,10 @@ fold_builtin_0 (tree fndecl, bool ignore ATTRIBUTE_UNUSED)
case BUILT_IN_INFD32:
case BUILT_IN_INFD64:
case BUILT_IN_INFD128:
- return fold_builtin_inf (type, true);
+ return fold_builtin_inf (loc, type, true);
CASE_FLT_FN (BUILT_IN_HUGE_VAL):
- return fold_builtin_inf (type, false);
+ return fold_builtin_inf (loc, type, false);
case BUILT_IN_CLASSIFY_TYPE:
return fold_builtin_classify_type (NULL_TREE);
@@ -10251,7 +10328,7 @@ fold_builtin_0 (tree fndecl, bool ignore ATTRIBUTE_UNUSED)
function returns NULL_TREE if no simplification was possible. */
static tree
-fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
+fold_builtin_1 (location_t loc, tree fndecl, tree arg0, bool ignore)
{
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
@@ -10275,39 +10352,39 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
return fold_builtin_classify_type (arg0);
case BUILT_IN_STRLEN:
- return fold_builtin_strlen (arg0);
+ return fold_builtin_strlen (loc, arg0);
CASE_FLT_FN (BUILT_IN_FABS):
- return fold_builtin_fabs (arg0, type);
+ return fold_builtin_fabs (loc, arg0, type);
case BUILT_IN_ABS:
case BUILT_IN_LABS:
case BUILT_IN_LLABS:
case BUILT_IN_IMAXABS:
- return fold_builtin_abs (arg0, type);
+ return fold_builtin_abs (loc, arg0, type);
CASE_FLT_FN (BUILT_IN_CONJ):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
- return fold_build1 (CONJ_EXPR, type, arg0);
+ return fold_build1_loc (loc, CONJ_EXPR, type, arg0);
break;
CASE_FLT_FN (BUILT_IN_CREAL):
if (validate_arg (arg0, COMPLEX_TYPE)
&& TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE)
- return non_lvalue (fold_build1 (REALPART_EXPR, type, arg0));;
+ return non_lvalue_loc (loc, fold_build1_loc (loc, REALPART_EXPR, type, arg0));;
break;
CASE_FLT_FN (BUILT_IN_CIMAG):
if (validate_arg (arg0, COMPLEX_TYPE))
- return non_lvalue (fold_build1 (IMAGPART_EXPR, type, arg0));
+ return non_lvalue_loc (loc, fold_build1_loc (loc, IMAGPART_EXPR, type, arg0));
break;
CASE_FLT_FN (BUILT_IN_CCOS):
- return fold_builtin_ccos(arg0, type, fndecl, /*hyper=*/ false);
+ return fold_builtin_ccos(loc, arg0, type, fndecl, /*hyper=*/ false);
CASE_FLT_FN (BUILT_IN_CCOSH):
- return fold_builtin_ccos(arg0, type, fndecl, /*hyper=*/ true);
+ return fold_builtin_ccos(loc, arg0, type, fndecl, /*hyper=*/ true);
#ifdef HAVE_mpc
CASE_FLT_FN (BUILT_IN_CSIN):
@@ -10348,16 +10425,16 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
#endif
CASE_FLT_FN (BUILT_IN_CABS):
- return fold_builtin_cabs (arg0, type, fndecl);
+ return fold_builtin_cabs (loc, arg0, type, fndecl);
CASE_FLT_FN (BUILT_IN_CARG):
- return fold_builtin_carg (arg0, type);
+ return fold_builtin_carg (loc, arg0, type);
CASE_FLT_FN (BUILT_IN_SQRT):
- return fold_builtin_sqrt (arg0, type);
+ return fold_builtin_sqrt (loc, arg0, type);
CASE_FLT_FN (BUILT_IN_CBRT):
- return fold_builtin_cbrt (arg0, type);
+ return fold_builtin_cbrt (loc, arg0, type);
CASE_FLT_FN (BUILT_IN_ASIN):
if (validate_arg (arg0, REAL_TYPE))
@@ -10399,13 +10476,13 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
break;
CASE_FLT_FN (BUILT_IN_COS):
- return fold_builtin_cos (arg0, type, fndecl);
+ return fold_builtin_cos (loc, arg0, type, fndecl);
CASE_FLT_FN (BUILT_IN_TAN):
return fold_builtin_tan (arg0, type);
CASE_FLT_FN (BUILT_IN_CEXP):
- return fold_builtin_cexp (arg0, type);
+ return fold_builtin_cexp (loc, arg0, type);
CASE_FLT_FN (BUILT_IN_CEXPI):
if (validate_arg (arg0, REAL_TYPE))
@@ -10418,7 +10495,7 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
break;
CASE_FLT_FN (BUILT_IN_COSH):
- return fold_builtin_cosh (arg0, type, fndecl);
+ return fold_builtin_cosh (loc, arg0, type, fndecl);
CASE_FLT_FN (BUILT_IN_TANH):
if (validate_arg (arg0, REAL_TYPE))
@@ -10441,14 +10518,14 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
break;
CASE_FLT_FN (BUILT_IN_EXP):
- return fold_builtin_exponent (fndecl, arg0, mpfr_exp);
+ return fold_builtin_exponent (loc, fndecl, arg0, mpfr_exp);
CASE_FLT_FN (BUILT_IN_EXP2):
- return fold_builtin_exponent (fndecl, arg0, mpfr_exp2);
+ return fold_builtin_exponent (loc, fndecl, arg0, mpfr_exp2);
CASE_FLT_FN (BUILT_IN_EXP10):
CASE_FLT_FN (BUILT_IN_POW10):
- return fold_builtin_exponent (fndecl, arg0, mpfr_exp10);
+ return fold_builtin_exponent (loc, fndecl, arg0, mpfr_exp10);
CASE_FLT_FN (BUILT_IN_EXPM1):
if (validate_arg (arg0, REAL_TYPE))
@@ -10456,13 +10533,13 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
break;
CASE_FLT_FN (BUILT_IN_LOG):
- return fold_builtin_logarithm (fndecl, arg0, mpfr_log);
+ return fold_builtin_logarithm (loc, fndecl, arg0, mpfr_log);
CASE_FLT_FN (BUILT_IN_LOG2):
- return fold_builtin_logarithm (fndecl, arg0, mpfr_log2);
+ return fold_builtin_logarithm (loc, fndecl, arg0, mpfr_log2);
CASE_FLT_FN (BUILT_IN_LOG10):
- return fold_builtin_logarithm (fndecl, arg0, mpfr_log10);
+ return fold_builtin_logarithm (loc, fndecl, arg0, mpfr_log10);
CASE_FLT_FN (BUILT_IN_LOG1P):
if (validate_arg (arg0, REAL_TYPE))
@@ -10504,20 +10581,20 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
return fold_builtin_nan (arg0, type, false);
CASE_FLT_FN (BUILT_IN_FLOOR):
- return fold_builtin_floor (fndecl, arg0);
+ return fold_builtin_floor (loc, fndecl, arg0);
CASE_FLT_FN (BUILT_IN_CEIL):
- return fold_builtin_ceil (fndecl, arg0);
+ return fold_builtin_ceil (loc, fndecl, arg0);
CASE_FLT_FN (BUILT_IN_TRUNC):
- return fold_builtin_trunc (fndecl, arg0);
+ return fold_builtin_trunc (loc, fndecl, arg0);
CASE_FLT_FN (BUILT_IN_ROUND):
- return fold_builtin_round (fndecl, arg0);
+ return fold_builtin_round (loc, fndecl, arg0);
CASE_FLT_FN (BUILT_IN_NEARBYINT):
CASE_FLT_FN (BUILT_IN_RINT):
- return fold_trunc_transparent_mathfn (fndecl, arg0);
+ return fold_trunc_transparent_mathfn (loc, fndecl, arg0);
CASE_FLT_FN (BUILT_IN_LCEIL):
CASE_FLT_FN (BUILT_IN_LLCEIL):
@@ -10525,11 +10602,11 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
CASE_FLT_FN (BUILT_IN_LLFLOOR):
CASE_FLT_FN (BUILT_IN_LROUND):
CASE_FLT_FN (BUILT_IN_LLROUND):
- return fold_builtin_int_roundingfn (fndecl, arg0);
+ return fold_builtin_int_roundingfn (loc, fndecl, arg0);
CASE_FLT_FN (BUILT_IN_LRINT):
CASE_FLT_FN (BUILT_IN_LLRINT):
- return fold_fixed_mathfn (fndecl, arg0);
+ return fold_fixed_mathfn (loc, fndecl, arg0);
case BUILT_IN_BSWAP32:
case BUILT_IN_BSWAP64:
@@ -10543,50 +10620,50 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
return fold_builtin_bitop (fndecl, arg0);
CASE_FLT_FN (BUILT_IN_SIGNBIT):
- return fold_builtin_signbit (arg0, type);
+ return fold_builtin_signbit (loc, arg0, type);
CASE_FLT_FN (BUILT_IN_SIGNIFICAND):
- return fold_builtin_significand (arg0, type);
+ return fold_builtin_significand (loc, arg0, type);
CASE_FLT_FN (BUILT_IN_ILOGB):
CASE_FLT_FN (BUILT_IN_LOGB):
- return fold_builtin_logb (arg0, type);
+ return fold_builtin_logb (loc, arg0, type);
case BUILT_IN_ISASCII:
- return fold_builtin_isascii (arg0);
+ return fold_builtin_isascii (loc, arg0);
case BUILT_IN_TOASCII:
- return fold_builtin_toascii (arg0);
+ return fold_builtin_toascii (loc, arg0);
case BUILT_IN_ISDIGIT:
- return fold_builtin_isdigit (arg0);
+ return fold_builtin_isdigit (loc, arg0);
CASE_FLT_FN (BUILT_IN_FINITE):
case BUILT_IN_FINITED32:
case BUILT_IN_FINITED64:
case BUILT_IN_FINITED128:
case BUILT_IN_ISFINITE:
- return fold_builtin_classify (fndecl, arg0, BUILT_IN_ISFINITE);
+ return fold_builtin_classify (loc, fndecl, arg0, BUILT_IN_ISFINITE);
CASE_FLT_FN (BUILT_IN_ISINF):
case BUILT_IN_ISINFD32:
case BUILT_IN_ISINFD64:
case BUILT_IN_ISINFD128:
- return fold_builtin_classify (fndecl, arg0, BUILT_IN_ISINF);
+ return fold_builtin_classify (loc, fndecl, arg0, BUILT_IN_ISINF);
case BUILT_IN_ISINF_SIGN:
- return fold_builtin_classify (fndecl, arg0, BUILT_IN_ISINF_SIGN);
+ return fold_builtin_classify (loc, fndecl, arg0, BUILT_IN_ISINF_SIGN);
CASE_FLT_FN (BUILT_IN_ISNAN):
case BUILT_IN_ISNAND32:
case BUILT_IN_ISNAND64:
case BUILT_IN_ISNAND128:
- return fold_builtin_classify (fndecl, arg0, BUILT_IN_ISNAN);
+ return fold_builtin_classify (loc, fndecl, arg0, BUILT_IN_ISNAN);
case BUILT_IN_PRINTF:
case BUILT_IN_PRINTF_UNLOCKED:
case BUILT_IN_VPRINTF:
- return fold_builtin_printf (fndecl, arg0, NULL_TREE, ignore, fcode);
+ return fold_builtin_printf (loc, fndecl, arg0, NULL_TREE, ignore, fcode);
default:
break;
@@ -10601,7 +10678,7 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore)
function returns NULL_TREE if no simplification was possible. */
static tree
-fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore)
+fold_builtin_2 (location_t loc, tree fndecl, tree arg0, tree arg1, bool ignore)
{
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
@@ -10648,7 +10725,7 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore)
break;
CASE_FLT_FN (BUILT_IN_HYPOT):
- return fold_builtin_hypot (fndecl, arg0, arg1, type);
+ return fold_builtin_hypot (loc, fndecl, arg0, arg1, type);
#ifdef HAVE_mpc_pow
CASE_FLT_FN (BUILT_IN_CPOW):
@@ -10661,48 +10738,49 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore)
#endif
CASE_FLT_FN (BUILT_IN_LDEXP):
- return fold_builtin_load_exponent (arg0, arg1, type, /*ldexp=*/true);
+ return fold_builtin_load_exponent (loc, arg0, arg1, type, /*ldexp=*/true);
CASE_FLT_FN (BUILT_IN_SCALBN):
CASE_FLT_FN (BUILT_IN_SCALBLN):
- return fold_builtin_load_exponent (arg0, arg1, type, /*ldexp=*/false);
+ return fold_builtin_load_exponent (loc, arg0, arg1,
+ type, /*ldexp=*/false);
CASE_FLT_FN (BUILT_IN_FREXP):
- return fold_builtin_frexp (arg0, arg1, type);
+ return fold_builtin_frexp (loc, arg0, arg1, type);
CASE_FLT_FN (BUILT_IN_MODF):
- return fold_builtin_modf (arg0, arg1, type);
+ return fold_builtin_modf (loc, arg0, arg1, type);
case BUILT_IN_BZERO:
- return fold_builtin_bzero (arg0, arg1, ignore);
+ return fold_builtin_bzero (loc, arg0, arg1, ignore);
case BUILT_IN_FPUTS:
- return fold_builtin_fputs (arg0, arg1, ignore, false, NULL_TREE);
+ return fold_builtin_fputs (loc, arg0, arg1, ignore, false, NULL_TREE);
case BUILT_IN_FPUTS_UNLOCKED:
- return fold_builtin_fputs (arg0, arg1, ignore, true, NULL_TREE);
+ return fold_builtin_fputs (loc, arg0, arg1, ignore, true, NULL_TREE);
case BUILT_IN_STRSTR:
- return fold_builtin_strstr (arg0, arg1, type);
+ return fold_builtin_strstr (loc, arg0, arg1, type);
case BUILT_IN_STRCAT:
- return fold_builtin_strcat (arg0, arg1);
+ return fold_builtin_strcat (loc, arg0, arg1);
case BUILT_IN_STRSPN:
- return fold_builtin_strspn (arg0, arg1);
+ return fold_builtin_strspn (loc, arg0, arg1);
case BUILT_IN_STRCSPN:
- return fold_builtin_strcspn (arg0, arg1);
+ return fold_builtin_strcspn (loc, arg0, arg1);
case BUILT_IN_STRCHR:
case BUILT_IN_INDEX:
- return fold_builtin_strchr (arg0, arg1, type);
+ return fold_builtin_strchr (loc, arg0, arg1, type);
case BUILT_IN_STRRCHR:
case BUILT_IN_RINDEX:
- return fold_builtin_strrchr (arg0, arg1, type);
+ return fold_builtin_strrchr (loc, arg0, arg1, type);
case BUILT_IN_STRCPY:
- return fold_builtin_strcpy (fndecl, arg0, arg1, NULL_TREE);
+ return fold_builtin_strcpy (loc, fndecl, arg0, arg1, NULL_TREE);
case BUILT_IN_STPCPY:
if (ignore)
@@ -10711,46 +10789,52 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore)
if (!fn)
break;
- return build_call_expr (fn, 2, arg0, arg1);
+ return build_call_expr_loc (loc, fn, 2, arg0, arg1);
}
break;
case BUILT_IN_STRCMP:
- return fold_builtin_strcmp (arg0, arg1);
+ return fold_builtin_strcmp (loc, arg0, arg1);
case BUILT_IN_STRPBRK:
- return fold_builtin_strpbrk (arg0, arg1, type);
+ return fold_builtin_strpbrk (loc, arg0, arg1, type);
case BUILT_IN_EXPECT:
- return fold_builtin_expect (arg0, arg1);
+ return fold_builtin_expect (loc, arg0, arg1);
CASE_FLT_FN (BUILT_IN_POW):
- return fold_builtin_pow (fndecl, arg0, arg1, type);
+ return fold_builtin_pow (loc, fndecl, arg0, arg1, type);
CASE_FLT_FN (BUILT_IN_POWI):
- return fold_builtin_powi (fndecl, arg0, arg1, type);
+ return fold_builtin_powi (loc, fndecl, arg0, arg1, type);
CASE_FLT_FN (BUILT_IN_COPYSIGN):
- return fold_builtin_copysign (fndecl, arg0, arg1, type);
+ return fold_builtin_copysign (loc, fndecl, arg0, arg1, type);
CASE_FLT_FN (BUILT_IN_FMIN):
- return fold_builtin_fmin_fmax (arg0, arg1, type, /*max=*/false);
+ return fold_builtin_fmin_fmax (loc, arg0, arg1, type, /*max=*/false);
CASE_FLT_FN (BUILT_IN_FMAX):
- return fold_builtin_fmin_fmax (arg0, arg1, type, /*max=*/true);
+ return fold_builtin_fmin_fmax (loc, arg0, arg1, type, /*max=*/true);
case BUILT_IN_ISGREATER:
- return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNLE_EXPR, LE_EXPR);
+ return fold_builtin_unordered_cmp (loc, fndecl,
+ arg0, arg1, UNLE_EXPR, LE_EXPR);
case BUILT_IN_ISGREATEREQUAL:
- return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNLT_EXPR, LT_EXPR);
+ return fold_builtin_unordered_cmp (loc, fndecl,
+ arg0, arg1, UNLT_EXPR, LT_EXPR);
case BUILT_IN_ISLESS:
- return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNGE_EXPR, GE_EXPR);
+ return fold_builtin_unordered_cmp (loc, fndecl,
+ arg0, arg1, UNGE_EXPR, GE_EXPR);
case BUILT_IN_ISLESSEQUAL:
- return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNGT_EXPR, GT_EXPR);
+ return fold_builtin_unordered_cmp (loc, fndecl,
+ arg0, arg1, UNGT_EXPR, GT_EXPR);
case BUILT_IN_ISLESSGREATER:
- return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNEQ_EXPR, EQ_EXPR);
+ return fold_builtin_unordered_cmp (loc, fndecl,
+ arg0, arg1, UNEQ_EXPR, EQ_EXPR);
case BUILT_IN_ISUNORDERED:
- return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNORDERED_EXPR,
+ return fold_builtin_unordered_cmp (loc, fndecl,
+ arg0, arg1, UNORDERED_EXPR,
NOP_EXPR);
/* We do the folding for va_start in the expander. */
@@ -10758,7 +10842,7 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore)
break;
case BUILT_IN_SPRINTF:
- return fold_builtin_sprintf (arg0, arg1, NULL_TREE, ignore);
+ return fold_builtin_sprintf (loc, arg0, arg1, NULL_TREE, ignore);
case BUILT_IN_OBJECT_SIZE:
return fold_builtin_object_size (arg0, arg1);
@@ -10766,7 +10850,7 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore)
case BUILT_IN_PRINTF:
case BUILT_IN_PRINTF_UNLOCKED:
case BUILT_IN_VPRINTF:
- return fold_builtin_printf (fndecl, arg0, arg1, ignore, fcode);
+ return fold_builtin_printf (loc, fndecl, arg0, arg1, ignore, fcode);
case BUILT_IN_PRINTF_CHK:
case BUILT_IN_VPRINTF_CHK:
@@ -10774,13 +10858,14 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore)
|| TREE_SIDE_EFFECTS (arg0))
return NULL_TREE;
else
- return fold_builtin_printf (fndecl, arg1, NULL_TREE, ignore, fcode);
+ return fold_builtin_printf (loc, fndecl,
+ arg1, NULL_TREE, ignore, fcode);
break;
case BUILT_IN_FPRINTF:
case BUILT_IN_FPRINTF_UNLOCKED:
case BUILT_IN_VFPRINTF:
- return fold_builtin_fprintf (fndecl, arg0, arg1, NULL_TREE,
+ return fold_builtin_fprintf (loc, fndecl, arg0, arg1, NULL_TREE,
ignore, fcode);
default:
@@ -10794,7 +10879,8 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore)
This function returns NULL_TREE if no simplification was possible. */
static tree
-fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore)
+fold_builtin_3 (location_t loc, tree fndecl,
+ tree arg0, tree arg1, tree arg2, bool ignore)
{
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
@@ -10802,7 +10888,7 @@ fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore)
{
CASE_FLT_FN (BUILT_IN_SINCOS):
- return fold_builtin_sincos (arg0, arg1, arg2);
+ return fold_builtin_sincos (loc, arg0, arg1, arg2);
CASE_FLT_FN (BUILT_IN_FMA):
if (validate_arg (arg0, REAL_TYPE)
@@ -10819,46 +10905,50 @@ fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore)
break;
case BUILT_IN_MEMSET:
- return fold_builtin_memset (arg0, arg1, arg2, type, ignore);
+ return fold_builtin_memset (loc, arg0, arg1, arg2, type, ignore);
case BUILT_IN_BCOPY:
- return fold_builtin_memory_op (arg1, arg0, arg2, void_type_node, true, /*endp=*/3);
+ return fold_builtin_memory_op (loc, arg1, arg0, arg2,
+ void_type_node, true, /*endp=*/3);
case BUILT_IN_MEMCPY:
- return fold_builtin_memory_op (arg0, arg1, arg2, type, ignore, /*endp=*/0);
+ return fold_builtin_memory_op (loc, arg0, arg1, arg2,
+ type, ignore, /*endp=*/0);
case BUILT_IN_MEMPCPY:
- return fold_builtin_memory_op (arg0, arg1, arg2, type, ignore, /*endp=*/1);
+ return fold_builtin_memory_op (loc, arg0, arg1, arg2,
+ type, ignore, /*endp=*/1);
case BUILT_IN_MEMMOVE:
- return fold_builtin_memory_op (arg0, arg1, arg2, type, ignore, /*endp=*/3);
+ return fold_builtin_memory_op (loc, arg0, arg1, arg2,
+ type, ignore, /*endp=*/3);
case BUILT_IN_STRNCAT:
- return fold_builtin_strncat (arg0, arg1, arg2);
+ return fold_builtin_strncat (loc, arg0, arg1, arg2);
case BUILT_IN_STRNCPY:
- return fold_builtin_strncpy (fndecl, arg0, arg1, arg2, NULL_TREE);
+ return fold_builtin_strncpy (loc, fndecl, arg0, arg1, arg2, NULL_TREE);
case BUILT_IN_STRNCMP:
- return fold_builtin_strncmp (arg0, arg1, arg2);
+ return fold_builtin_strncmp (loc, arg0, arg1, arg2);
case BUILT_IN_MEMCHR:
- return fold_builtin_memchr (arg0, arg1, arg2, type);
+ return fold_builtin_memchr (loc, arg0, arg1, arg2, type);
case BUILT_IN_BCMP:
case BUILT_IN_MEMCMP:
- return fold_builtin_memcmp (arg0, arg1, arg2);;
+ return fold_builtin_memcmp (loc, arg0, arg1, arg2);;
case BUILT_IN_SPRINTF:
- return fold_builtin_sprintf (arg0, arg1, arg2, ignore);
+ return fold_builtin_sprintf (loc, arg0, arg1, arg2, ignore);
case BUILT_IN_STRCPY_CHK:
case BUILT_IN_STPCPY_CHK:
- return fold_builtin_stxcpy_chk (fndecl, arg0, arg1, arg2, NULL_TREE,
+ return fold_builtin_stxcpy_chk (loc, fndecl, arg0, arg1, arg2, NULL_TREE,
ignore, fcode);
case BUILT_IN_STRCAT_CHK:
- return fold_builtin_strcat_chk (fndecl, arg0, arg1, arg2);
+ return fold_builtin_strcat_chk (loc, fndecl, arg0, arg1, arg2);
case BUILT_IN_PRINTF_CHK:
case BUILT_IN_VPRINTF_CHK:
@@ -10866,13 +10956,14 @@ fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore)
|| TREE_SIDE_EFFECTS (arg0))
return NULL_TREE;
else
- return fold_builtin_printf (fndecl, arg1, arg2, ignore, fcode);
+ return fold_builtin_printf (loc, fndecl, arg1, arg2, ignore, fcode);
break;
case BUILT_IN_FPRINTF:
case BUILT_IN_FPRINTF_UNLOCKED:
case BUILT_IN_VFPRINTF:
- return fold_builtin_fprintf (fndecl, arg0, arg1, arg2, ignore, fcode);
+ return fold_builtin_fprintf (loc, fndecl, arg0, arg1, arg2,
+ ignore, fcode);
case BUILT_IN_FPRINTF_CHK:
case BUILT_IN_VFPRINTF_CHK:
@@ -10880,7 +10971,7 @@ fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore)
|| TREE_SIDE_EFFECTS (arg1))
return NULL_TREE;
else
- return fold_builtin_fprintf (fndecl, arg0, arg2, NULL_TREE,
+ return fold_builtin_fprintf (loc, fndecl, arg0, arg2, NULL_TREE,
ignore, fcode);
default:
@@ -10895,8 +10986,8 @@ fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore)
possible. */
static tree
-fold_builtin_4 (tree fndecl, tree arg0, tree arg1, tree arg2, tree arg3,
- bool ignore)
+fold_builtin_4 (location_t loc, tree fndecl,
+ tree arg0, tree arg1, tree arg2, tree arg3, bool ignore)
{
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
@@ -10906,15 +10997,15 @@ fold_builtin_4 (tree fndecl, tree arg0, tree arg1, tree arg2, tree arg3,
case BUILT_IN_MEMPCPY_CHK:
case BUILT_IN_MEMMOVE_CHK:
case BUILT_IN_MEMSET_CHK:
- return fold_builtin_memory_chk (fndecl, arg0, arg1, arg2, arg3,
+ return fold_builtin_memory_chk (loc, fndecl, arg0, arg1, arg2, arg3,
NULL_TREE, ignore,
DECL_FUNCTION_CODE (fndecl));
case BUILT_IN_STRNCPY_CHK:
- return fold_builtin_strncpy_chk (arg0, arg1, arg2, arg3, NULL_TREE);
+ return fold_builtin_strncpy_chk (loc, arg0, arg1, arg2, arg3, NULL_TREE);
case BUILT_IN_STRNCAT_CHK:
- return fold_builtin_strncat_chk (fndecl, arg0, arg1, arg2, arg3);
+ return fold_builtin_strncat_chk (loc, fndecl, arg0, arg1, arg2, arg3);
case BUILT_IN_FPRINTF_CHK:
case BUILT_IN_VFPRINTF_CHK:
@@ -10922,7 +11013,7 @@ fold_builtin_4 (tree fndecl, tree arg0, tree arg1, tree arg2, tree arg3,
|| TREE_SIDE_EFFECTS (arg1))
return NULL_TREE;
else
- return fold_builtin_fprintf (fndecl, arg0, arg2, arg3,
+ return fold_builtin_fprintf (loc, fndecl, arg0, arg2, arg3,
ignore, fcode);
break;
@@ -10943,26 +11034,26 @@ fold_builtin_4 (tree fndecl, tree arg0, tree arg1, tree arg2, tree arg3,
#define MAX_ARGS_TO_FOLD_BUILTIN 4
static tree
-fold_builtin_n (tree fndecl, tree *args, int nargs, bool ignore)
+fold_builtin_n (location_t loc, tree fndecl, tree *args, int nargs, bool ignore)
{
tree ret = NULL_TREE;
switch (nargs)
{
case 0:
- ret = fold_builtin_0 (fndecl, ignore);
+ ret = fold_builtin_0 (loc, fndecl, ignore);
break;
case 1:
- ret = fold_builtin_1 (fndecl, args[0], ignore);
+ ret = fold_builtin_1 (loc, fndecl, args[0], ignore);
break;
case 2:
- ret = fold_builtin_2 (fndecl, args[0], args[1], ignore);
+ ret = fold_builtin_2 (loc, fndecl, args[0], args[1], ignore);
break;
case 3:
- ret = fold_builtin_3 (fndecl, args[0], args[1], args[2], ignore);
+ ret = fold_builtin_3 (loc, fndecl, args[0], args[1], args[2], ignore);
break;
case 4:
- ret = fold_builtin_4 (fndecl, args[0], args[1], args[2], args[3],
+ ret = fold_builtin_4 (loc, fndecl, args[0], args[1], args[2], args[3],
ignore);
break;
default:
@@ -10971,6 +11062,7 @@ fold_builtin_n (tree fndecl, tree *args, int nargs, bool ignore)
if (ret)
{
ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret);
+ SET_EXPR_LOCATION (ret, loc);
TREE_NO_WARNING (ret) = 1;
return ret;
}
@@ -10985,7 +11077,8 @@ fold_builtin_n (tree fndecl, tree *args, int nargs, bool ignore)
result of the function call is ignored. */
static tree
-fold_builtin_varargs (tree fndecl, tree exp, bool ignore ATTRIBUTE_UNUSED)
+fold_builtin_varargs (location_t loc, tree fndecl, tree exp,
+ bool ignore ATTRIBUTE_UNUSED)
{
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
tree ret = NULL_TREE;
@@ -10994,16 +11087,16 @@ fold_builtin_varargs (tree fndecl, tree exp, bool ignore ATTRIBUTE_UNUSED)
{
case BUILT_IN_SPRINTF_CHK:
case BUILT_IN_VSPRINTF_CHK:
- ret = fold_builtin_sprintf_chk (exp, fcode);
+ ret = fold_builtin_sprintf_chk (loc, exp, fcode);
break;
case BUILT_IN_SNPRINTF_CHK:
case BUILT_IN_VSNPRINTF_CHK:
- ret = fold_builtin_snprintf_chk (exp, NULL_TREE, fcode);
+ ret = fold_builtin_snprintf_chk (loc, exp, NULL_TREE, fcode);
break;
case BUILT_IN_FPCLASSIFY:
- ret = fold_builtin_fpclassify (exp);
+ ret = fold_builtin_fpclassify (loc, exp);
break;
default:
@@ -11012,6 +11105,7 @@ fold_builtin_varargs (tree fndecl, tree exp, bool ignore ATTRIBUTE_UNUSED)
if (ret)
{
ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret);
+ SET_EXPR_LOCATION (ret, loc);
TREE_NO_WARNING (ret) = 1;
return ret;
}
@@ -11039,7 +11133,7 @@ avoid_folding_inline_builtin (tree fndecl)
call node earlier than the warning is generated. */
tree
-fold_call_expr (tree exp, bool ignore)
+fold_call_expr (location_t loc, tree exp, bool ignore)
{
tree ret = NULL_TREE;
tree fndecl = get_callee_fndecl (exp);
@@ -11077,27 +11171,12 @@ fold_call_expr (tree exp, bool ignore)
if (nargs <= MAX_ARGS_TO_FOLD_BUILTIN)
{
tree *args = CALL_EXPR_ARGP (exp);
- ret = fold_builtin_n (fndecl, args, nargs, ignore);
+ ret = fold_builtin_n (loc, fndecl, args, nargs, ignore);
}
if (!ret)
- ret = fold_builtin_varargs (fndecl, exp, ignore);
+ ret = fold_builtin_varargs (loc, fndecl, exp, ignore);
if (ret)
- {
- /* Propagate location information from original call to
- expansion of builtin. Otherwise things like
- maybe_emit_chk_warning, that operate on the expansion
- of a builtin, will use the wrong location information. */
- if (CAN_HAVE_LOCATION_P (exp) && EXPR_HAS_LOCATION (exp))
- {
- tree realret = ret;
- if (TREE_CODE (ret) == NOP_EXPR)
- realret = TREE_OPERAND (ret, 0);
- if (CAN_HAVE_LOCATION_P (realret)
- && !EXPR_HAS_LOCATION (realret))
- SET_EXPR_LOCATION (realret, EXPR_LOCATION (exp));
- }
- return ret;
- }
+ return ret;
}
}
return NULL_TREE;
@@ -11107,17 +11186,17 @@ fold_call_expr (tree exp, bool ignore)
function to be called and ARGLIST is a TREE_LIST of arguments. */
tree
-build_function_call_expr (tree fndecl, tree arglist)
+build_function_call_expr (location_t loc, tree fndecl, tree arglist)
{
tree fntype = TREE_TYPE (fndecl);
tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
int n = list_length (arglist);
tree *argarray = (tree *) alloca (n * sizeof (tree));
int i;
-
+
for (i = 0; i < n; i++, arglist = TREE_CHAIN (arglist))
argarray[i] = TREE_VALUE (arglist);
- return fold_builtin_call_array (TREE_TYPE (fntype), fn, n, argarray);
+ return fold_builtin_call_array (loc, TREE_TYPE (fntype), fn, n, argarray);
}
/* Conveniently construct a function call expression. FNDECL names the
@@ -11125,7 +11204,7 @@ build_function_call_expr (tree fndecl, tree arglist)
parameters are the argument expressions. */
tree
-build_call_expr (tree fndecl, int n, ...)
+build_call_expr_loc (location_t loc, tree fndecl, int n, ...)
{
va_list ap;
tree fntype = TREE_TYPE (fndecl);
@@ -11137,14 +11216,14 @@ build_call_expr (tree fndecl, int n, ...)
for (i = 0; i < n; i++)
argarray[i] = va_arg (ap, tree);
va_end (ap);
- return fold_builtin_call_array (TREE_TYPE (fntype), fn, n, argarray);
+ return fold_builtin_call_array (loc, TREE_TYPE (fntype), fn, n, argarray);
}
/* Construct a CALL_EXPR with type TYPE with FN as the function expression.
N arguments are passed in the array ARGARRAY. */
tree
-fold_builtin_call_array (tree type,
+fold_builtin_call_array (location_t loc, tree type,
tree fn,
int n,
tree *argarray)
@@ -11168,10 +11247,10 @@ fold_builtin_call_array (tree type,
&& TREE_CODE (fndecl2) == FUNCTION_DECL
&& DECL_BUILT_IN_CLASS (fndecl2) == BUILT_IN_NORMAL
&& DECL_FUNCTION_CODE (fndecl2) == BUILT_IN_VA_ARG_PACK)
- return build_call_array (type, fn, n, argarray);
+ return build_call_array_loc (loc, type, fn, n, argarray);
}
if (avoid_folding_inline_builtin (fndecl))
- return build_call_array (type, fn, n, argarray);
+ return build_call_array_loc (loc, type, fn, n, argarray);
if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
{
tree arglist = NULL_TREE;
@@ -11180,25 +11259,25 @@ fold_builtin_call_array (tree type,
ret = targetm.fold_builtin (fndecl, arglist, false);
if (ret)
return ret;
- return build_call_array (type, fn, n, argarray);
+ return build_call_array_loc (loc, type, fn, n, argarray);
}
else if (n <= MAX_ARGS_TO_FOLD_BUILTIN)
{
/* First try the transformations that don't require consing up
an exp. */
- ret = fold_builtin_n (fndecl, argarray, n, false);
+ ret = fold_builtin_n (loc, fndecl, argarray, n, false);
if (ret)
return ret;
}
/* If we got this far, we need to build an exp. */
- exp = build_call_array (type, fn, n, argarray);
- ret = fold_builtin_varargs (fndecl, exp, false);
+ exp = build_call_array_loc (loc, type, fn, n, argarray);
+ ret = fold_builtin_varargs (loc, fndecl, exp, false);
return ret ? ret : exp;
}
}
- return build_call_array (type, fn, n, argarray);
+ return build_call_array_loc (loc, type, fn, n, argarray);
}
/* Construct a new CALL_EXPR using the tail of the argument list of EXP
@@ -11207,7 +11286,7 @@ fold_builtin_call_array (tree type,
to do varargs-to-varargs transformations. */
static tree
-rewrite_call_expr (tree exp, int skip, tree fndecl, int n, ...)
+rewrite_call_expr (location_t loc, tree exp, int skip, tree fndecl, int n, ...)
{
int oldnargs = call_expr_nargs (exp);
int nargs = oldnargs - skip + n;
@@ -11231,7 +11310,7 @@ rewrite_call_expr (tree exp, int skip, tree fndecl, int n, ...)
else
buffer = CALL_EXPR_ARGP (exp) + skip;
- return fold (build_call_array (TREE_TYPE (exp), fn, nargs, buffer));
+ return fold (build_call_array_loc (loc, TREE_TYPE (exp), fn, nargs, buffer));
}
/* Validate a single argument ARG against a tree code CODE representing
@@ -11412,7 +11491,7 @@ readonly_data_expr (tree exp)
form of the builtin function call. */
static tree
-fold_builtin_strstr (tree s1, tree s2, tree type)
+fold_builtin_strstr (location_t loc, tree s1, tree s2, tree type)
{
if (!validate_arg (s1, POINTER_TYPE)
|| !validate_arg (s2, POINTER_TYPE))
@@ -11436,15 +11515,15 @@ fold_builtin_strstr (tree s1, tree s2, tree type)
return build_int_cst (TREE_TYPE (s1), 0);
/* Return an offset into the constant string argument. */
- tem = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (s1),
+ tem = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (s1),
s1, size_int (r - p1));
- return fold_convert (type, tem);
+ return fold_convert_loc (loc, type, tem);
}
/* The argument is const char *, and the result is char *, so we need
a type conversion here to avoid a warning. */
if (p2[0] == '\0')
- return fold_convert (type, s1);
+ return fold_convert_loc (loc, type, s1);
if (p2[1] != '\0')
return NULL_TREE;
@@ -11455,7 +11534,7 @@ fold_builtin_strstr (tree s1, tree s2, tree type)
/* New argument list transforming strstr(s1, s2) to
strchr(s1, s2[0]). */
- return build_call_expr (fn, 2, s1, build_int_cst (NULL_TREE, p2[0]));
+ return build_call_expr_loc (loc, fn, 2, s1, build_int_cst (NULL_TREE, p2[0]));
}
}
@@ -11478,7 +11557,7 @@ fold_builtin_strstr (tree s1, tree s2, tree type)
form of the builtin function call. */
static tree
-fold_builtin_strchr (tree s1, tree s2, tree type)
+fold_builtin_strchr (location_t loc, tree s1, tree s2, tree type)
{
if (!validate_arg (s1, POINTER_TYPE)
|| !validate_arg (s2, INTEGER_TYPE))
@@ -11506,9 +11585,9 @@ fold_builtin_strchr (tree s1, tree s2, tree type)
return build_int_cst (TREE_TYPE (s1), 0);
/* Return an offset into the constant string argument. */
- tem = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (s1),
+ tem = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (s1),
s1, size_int (r - p1));
- return fold_convert (type, tem);
+ return fold_convert_loc (loc, type, tem);
}
return NULL_TREE;
}
@@ -11533,7 +11612,7 @@ fold_builtin_strchr (tree s1, tree s2, tree type)
form of the builtin function call. */
static tree
-fold_builtin_strrchr (tree s1, tree s2, tree type)
+fold_builtin_strrchr (location_t loc, tree s1, tree s2, tree type)
{
if (!validate_arg (s1, POINTER_TYPE)
|| !validate_arg (s2, INTEGER_TYPE))
@@ -11562,9 +11641,9 @@ fold_builtin_strrchr (tree s1, tree s2, tree type)
return build_int_cst (TREE_TYPE (s1), 0);
/* Return an offset into the constant string argument. */
- tem = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (s1),
+ tem = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (s1),
s1, size_int (r - p1));
- return fold_convert (type, tem);
+ return fold_convert_loc (loc, type, tem);
}
if (! integer_zerop (s2))
@@ -11575,7 +11654,7 @@ fold_builtin_strrchr (tree s1, tree s2, tree type)
return NULL_TREE;
/* Transform strrchr(s1, '\0') to strchr(s1, '\0'). */
- return build_call_expr (fn, 2, s1, s2);
+ return build_call_expr_loc (loc, fn, 2, s1, s2);
}
}
@@ -11598,7 +11677,7 @@ fold_builtin_strrchr (tree s1, tree s2, tree type)
form of the builtin function call. */
static tree
-fold_builtin_strpbrk (tree s1, tree s2, tree type)
+fold_builtin_strpbrk (location_t loc, tree s1, tree s2, tree type)
{
if (!validate_arg (s1, POINTER_TYPE)
|| !validate_arg (s2, POINTER_TYPE))
@@ -11622,15 +11701,15 @@ fold_builtin_strpbrk (tree s1, tree s2, tree type)
return build_int_cst (TREE_TYPE (s1), 0);
/* Return an offset into the constant string argument. */
- tem = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (s1),
+ tem = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (s1),
s1, size_int (r - p1));
- return fold_convert (type, tem);
+ return fold_convert_loc (loc, type, tem);
}
if (p2[0] == '\0')
/* strpbrk(x, "") == NULL.
Evaluate and ignore s1 in case it had side-effects. */
- return omit_one_operand (TREE_TYPE (s1), integer_zero_node, s1);
+ return omit_one_operand_loc (loc, TREE_TYPE (s1), integer_zero_node, s1);
if (p2[1] != '\0')
return NULL_TREE; /* Really call strpbrk. */
@@ -11641,7 +11720,7 @@ fold_builtin_strpbrk (tree s1, tree s2, tree type)
/* New argument list transforming strpbrk(s1, s2) to
strchr(s1, s2[0]). */
- return build_call_expr (fn, 2, s1, build_int_cst (NULL_TREE, p2[0]));
+ return build_call_expr_loc (loc, fn, 2, s1, build_int_cst (NULL_TREE, p2[0]));
}
}
@@ -11664,7 +11743,7 @@ fold_builtin_strpbrk (tree s1, tree s2, tree type)
form of the builtin function call. */
static tree
-fold_builtin_strcat (tree dst, tree src)
+fold_builtin_strcat (location_t loc ATTRIBUTE_UNUSED, tree dst, tree src)
{
if (!validate_arg (dst, POINTER_TYPE)
|| !validate_arg (src, POINTER_TYPE))
@@ -11700,7 +11779,7 @@ fold_builtin_strcat (tree dst, tree src)
form of the builtin function call. */
static tree
-fold_builtin_strncat (tree dst, tree src, tree len)
+fold_builtin_strncat (location_t loc, tree dst, tree src, tree len)
{
if (!validate_arg (dst, POINTER_TYPE)
|| !validate_arg (src, POINTER_TYPE)
@@ -11713,7 +11792,7 @@ fold_builtin_strncat (tree dst, tree src, tree len)
/* If the requested length is zero, or the src parameter string
length is zero, return the dst parameter. */
if (integer_zerop (len) || (p && *p == '\0'))
- return omit_two_operands (TREE_TYPE (dst), dst, src, len);
+ return omit_two_operands_loc (loc, TREE_TYPE (dst), dst, src, len);
/* If the requested len is greater than or equal to the string
length, call strcat. */
@@ -11727,7 +11806,7 @@ fold_builtin_strncat (tree dst, tree src, tree len)
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 2, dst, src);
+ return build_call_expr_loc (loc, fn, 2, dst, src);
}
return NULL_TREE;
}
@@ -11752,7 +11831,7 @@ fold_builtin_strncat (tree dst, tree src, tree len)
form of the builtin function call. */
static tree
-fold_builtin_strspn (tree s1, tree s2)
+fold_builtin_strspn (location_t loc, tree s1, tree s2)
{
if (!validate_arg (s1, POINTER_TYPE)
|| !validate_arg (s2, POINTER_TYPE))
@@ -11772,7 +11851,7 @@ fold_builtin_strspn (tree s1, tree s2)
if ((p1 && *p1 == '\0') || (p2 && *p2 == '\0'))
/* Evaluate and ignore both arguments in case either one has
side-effects. */
- return omit_two_operands (size_type_node, size_zero_node,
+ return omit_two_operands_loc (loc, size_type_node, size_zero_node,
s1, s2);
return NULL_TREE;
}
@@ -11797,7 +11876,7 @@ fold_builtin_strspn (tree s1, tree s2)
form of the builtin function call. */
static tree
-fold_builtin_strcspn (tree s1, tree s2)
+fold_builtin_strcspn (location_t loc, tree s1, tree s2)
{
if (!validate_arg (s1, POINTER_TYPE)
|| !validate_arg (s2, POINTER_TYPE))
@@ -11818,7 +11897,7 @@ fold_builtin_strcspn (tree s1, tree s2)
{
/* Evaluate and ignore argument s2 in case it has
side-effects. */
- return omit_one_operand (size_type_node,
+ return omit_one_operand_loc (loc, size_type_node,
size_zero_node, s2);
}
@@ -11832,7 +11911,7 @@ fold_builtin_strcspn (tree s1, tree s2)
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 1, s1);
+ return build_call_expr_loc (loc, fn, 1, s1);
}
return NULL_TREE;
}
@@ -11846,7 +11925,8 @@ fold_builtin_strcspn (tree s1, tree s2)
was possible. */
tree
-fold_builtin_fputs (tree arg0, tree arg1, bool ignore, bool unlocked, tree len)
+fold_builtin_fputs (location_t loc, tree arg0, tree arg1,
+ bool ignore, bool unlocked, tree len)
{
/* If we're using an unlocked function, assume the other unlocked
functions exist explicitly. */
@@ -11876,7 +11956,8 @@ fold_builtin_fputs (tree arg0, tree arg1, bool ignore, bool unlocked, tree len)
switch (compare_tree_int (len, 1))
{
case -1: /* length is 0, delete the call entirely . */
- return omit_one_operand (integer_type_node, integer_zero_node, arg1);;
+ return omit_one_operand_loc (loc, integer_type_node,
+ integer_zero_node, arg1);;
case 0: /* length is 1, call fputc. */
{
@@ -11885,7 +11966,7 @@ fold_builtin_fputs (tree arg0, tree arg1, bool ignore, bool unlocked, tree len)
if (p != NULL)
{
if (fn_fputc)
- return build_call_expr (fn_fputc, 2,
+ return build_call_expr_loc (loc, fn_fputc, 2,
build_int_cst (NULL_TREE, p[0]), arg1);
else
return NULL_TREE;
@@ -11900,7 +11981,8 @@ fold_builtin_fputs (tree arg0, tree arg1, bool ignore, bool unlocked, tree len)
/* New argument list transforming fputs(string, stream) to
fwrite(string, 1, len, stream). */
if (fn_fwrite)
- return build_call_expr (fn_fwrite, 4, arg0, size_one_node, len, arg1);
+ return build_call_expr_loc (loc, fn_fwrite, 4, arg0,
+ size_one_node, len, arg1);
else
return NULL_TREE;
}
@@ -12017,7 +12099,8 @@ fold_builtin_next_arg (tree exp, bool va_start_p)
the caller does not use the returned value of the function. */
static tree
-fold_builtin_sprintf (tree dest, tree fmt, tree orig, int ignored)
+fold_builtin_sprintf (location_t loc, tree dest, tree fmt,
+ tree orig, int ignored)
{
tree call, retval;
const char *fmt_str = NULL;
@@ -12056,7 +12139,7 @@ fold_builtin_sprintf (tree dest, tree fmt, tree orig, int ignored)
/* Convert sprintf (str, fmt) into strcpy (str, fmt) when
'format' is known to contain no % formats. */
- call = build_call_expr (fn, 2, dest, fmt);
+ call = build_call_expr_loc (loc, fn, 2, dest, fmt);
if (!ignored)
retval = build_int_cst (NULL_TREE, strlen (fmt_str));
}
@@ -12081,13 +12164,13 @@ fold_builtin_sprintf (tree dest, tree fmt, tree orig, int ignored)
if (!retval || TREE_CODE (retval) != INTEGER_CST)
return NULL_TREE;
}
- call = build_call_expr (fn, 2, dest, orig);
+ call = build_call_expr_loc (loc, fn, 2, dest, orig);
}
if (call && retval)
{
- retval = fold_convert
- (TREE_TYPE (TREE_TYPE (implicit_built_in_decls[BUILT_IN_SPRINTF])),
+ retval = fold_convert_loc
+ (loc, TREE_TYPE (TREE_TYPE (implicit_built_in_decls[BUILT_IN_SPRINTF])),
retval);
return build2 (COMPOUND_EXPR, TREE_TYPE (retval), call, retval);
}
@@ -12478,7 +12561,7 @@ fold_builtin_object_size (tree ptr, tree ost)
passed as third argument. */
tree
-fold_builtin_memory_chk (tree fndecl,
+fold_builtin_memory_chk (location_t loc, tree fndecl,
tree dest, tree src, tree len, tree size,
tree maxlen, bool ignore,
enum built_in_function fcode)
@@ -12498,11 +12581,13 @@ fold_builtin_memory_chk (tree fndecl,
if (fcode != BUILT_IN_MEMSET_CHK && operand_equal_p (src, dest, 0))
{
if (fcode != BUILT_IN_MEMPCPY_CHK)
- return omit_one_operand (TREE_TYPE (TREE_TYPE (fndecl)), dest, len);
+ return omit_one_operand_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)),
+ dest, len);
else
{
- tree temp = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dest), dest, len);
- return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), temp);
+ tree temp = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (dest),
+ dest, len);
+ return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), temp);
}
}
@@ -12526,7 +12611,7 @@ fold_builtin_memory_chk (tree fndecl,
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 4, dest, src, len, size);
+ return build_call_expr_loc (loc, fn, 4, dest, src, len, size);
}
return NULL_TREE;
}
@@ -12562,7 +12647,7 @@ fold_builtin_memory_chk (tree fndecl,
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 3, dest, src, len);
+ return build_call_expr_loc (loc, fn, 3, dest, src, len);
}
/* Fold a call to the __st[rp]cpy_chk builtin.
@@ -12572,7 +12657,8 @@ fold_builtin_memory_chk (tree fndecl,
strings passed as second argument. */
tree
-fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size,
+fold_builtin_stxcpy_chk (location_t loc, tree fndecl, tree dest,
+ tree src, tree size,
tree maxlen, bool ignore,
enum built_in_function fcode)
{
@@ -12585,7 +12671,7 @@ fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size,
/* If SRC and DEST are the same (and not volatile), return DEST. */
if (fcode == BUILT_IN_STRCPY_CHK && operand_equal_p (src, dest, 0))
- return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), dest);
+ return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest);
if (! host_integerp (size, 1))
return NULL_TREE;
@@ -12611,7 +12697,7 @@ fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size,
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 3, dest, src, size);
+ return build_call_expr_loc (loc, fn, 3, dest, src, size);
}
if (! len || TREE_SIDE_EFFECTS (len))
@@ -12623,10 +12709,10 @@ fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size,
if (!fn)
return NULL_TREE;
- len = size_binop (PLUS_EXPR, len, ssize_int (1));
- return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)),
- build_call_expr (fn, 4,
- dest, src, len, size));
+ len = size_binop_loc (loc, PLUS_EXPR, len, ssize_int (1));
+ return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)),
+ build_call_expr_loc (loc, fn, 4,
+ dest, src, len, size));
}
}
else
@@ -12642,7 +12728,7 @@ fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size,
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 2, dest, src);
+ return build_call_expr_loc (loc, fn, 2, dest, src);
}
/* Fold a call to the __strncpy_chk builtin. DEST, SRC, LEN, and SIZE
@@ -12650,8 +12736,8 @@ fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size,
length passed as third argument. */
tree
-fold_builtin_strncpy_chk (tree dest, tree src, tree len, tree size,
- tree maxlen)
+fold_builtin_strncpy_chk (location_t loc, tree dest, tree src,
+ tree len, tree size, tree maxlen)
{
tree fn;
@@ -12686,14 +12772,15 @@ fold_builtin_strncpy_chk (tree dest, tree src, tree len, tree size,
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 3, dest, src, len);
+ return build_call_expr_loc (loc, fn, 3, dest, src, len);
}
/* Fold a call to the __strcat_chk builtin FNDECL. DEST, SRC, and SIZE
are the arguments to the call. */
static tree
-fold_builtin_strcat_chk (tree fndecl, tree dest, tree src, tree size)
+fold_builtin_strcat_chk (location_t loc, tree fndecl, tree dest,
+ tree src, tree size)
{
tree fn;
const char *p;
@@ -12706,7 +12793,7 @@ fold_builtin_strcat_chk (tree fndecl, tree dest, tree src, tree size)
p = c_getstr (src);
/* If the SRC parameter is "", return DEST. */
if (p && *p == '\0')
- return omit_one_operand (TREE_TYPE (TREE_TYPE (fndecl)), dest, src);
+ return omit_one_operand_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest, src);
if (! host_integerp (size, 1) || ! integer_all_onesp (size))
return NULL_TREE;
@@ -12716,14 +12803,14 @@ fold_builtin_strcat_chk (tree fndecl, tree dest, tree src, tree size)
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 2, dest, src);
+ return build_call_expr_loc (loc, fn, 2, dest, src);
}
/* Fold a call to the __strncat_chk builtin with arguments DEST, SRC,
LEN, and SIZE. */
static tree
-fold_builtin_strncat_chk (tree fndecl,
+fold_builtin_strncat_chk (location_t loc, tree fndecl,
tree dest, tree src, tree len, tree size)
{
tree fn;
@@ -12738,9 +12825,9 @@ fold_builtin_strncat_chk (tree fndecl,
p = c_getstr (src);
/* If the SRC parameter is "" or if LEN is 0, return DEST. */
if (p && *p == '\0')
- return omit_one_operand (TREE_TYPE (TREE_TYPE (fndecl)), dest, len);
+ return omit_one_operand_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest, len);
else if (integer_zerop (len))
- return omit_one_operand (TREE_TYPE (TREE_TYPE (fndecl)), dest, src);
+ return omit_one_operand_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest, src);
if (! host_integerp (size, 1))
return NULL_TREE;
@@ -12758,7 +12845,7 @@ fold_builtin_strncat_chk (tree fndecl,
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 3, dest, src, size);
+ return build_call_expr_loc (loc, fn, 3, dest, src, size);
}
return NULL_TREE;
}
@@ -12768,7 +12855,7 @@ fold_builtin_strncat_chk (tree fndecl,
if (!fn)
return NULL_TREE;
- return build_call_expr (fn, 3, dest, src, len);
+ return build_call_expr_loc (loc, fn, 3, dest, src, len);
}
/* Fold a call EXP to __{,v}sprintf_chk. Return NULL_TREE if
@@ -12776,7 +12863,8 @@ fold_builtin_strncat_chk (tree fndecl,
inline. FCODE is either BUILT_IN_SPRINTF_CHK or BUILT_IN_VSPRINTF_CHK. */
static tree
-fold_builtin_sprintf_chk (tree exp, enum built_in_function fcode)
+fold_builtin_sprintf_chk (location_t loc, tree exp,
+ enum built_in_function fcode)
{
tree dest, size, len, fn, fmt, flag;
const char *fmt_str;
@@ -12859,7 +12947,7 @@ fold_builtin_sprintf_chk (tree exp, enum built_in_function fcode)
if (!fn)
return NULL_TREE;
- return rewrite_call_expr (exp, 4, fn, 2, dest, fmt);
+ return rewrite_call_expr (loc, exp, 4, fn, 2, dest, fmt);
}
/* Fold a call EXP to {,v}snprintf. Return NULL_TREE if
@@ -12869,7 +12957,7 @@ fold_builtin_sprintf_chk (tree exp, enum built_in_function fcode)
passed as second argument. */
tree
-fold_builtin_snprintf_chk (tree exp, tree maxlen,
+fold_builtin_snprintf_chk (location_t loc, tree exp, tree maxlen,
enum built_in_function fcode)
{
tree dest, size, len, fn, fmt, flag;
@@ -12936,7 +13024,7 @@ fold_builtin_snprintf_chk (tree exp, tree maxlen,
if (!fn)
return NULL_TREE;
- return rewrite_call_expr (exp, 5, fn, 3, dest, len, fmt);
+ return rewrite_call_expr (loc, exp, 5, fn, 3, dest, len, fmt);
}
/* Fold a call to the {,v}printf{,_unlocked} and __{,v}printf_chk builtins.
@@ -12948,7 +13036,8 @@ fold_builtin_snprintf_chk (tree exp, tree maxlen,
code of the function to be simplified. */
static tree
-fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore,
+fold_builtin_printf (location_t loc, tree fndecl, tree fmt,
+ tree arg, bool ignore,
enum built_in_function fcode)
{
tree fn_putchar, fn_puts, newarg, call = NULL_TREE;
@@ -13021,7 +13110,7 @@ fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore,
function. */
newarg = build_int_cst (NULL_TREE, str[0]);
if (fn_putchar)
- call = build_call_expr (fn_putchar, 1, newarg);
+ call = build_call_expr_loc (loc, fn_putchar, 1, newarg);
}
else
{
@@ -13037,7 +13126,7 @@ fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore,
newarg = build_string_literal (len, newstr);
if (fn_puts)
- call = build_call_expr (fn_puts, 1, newarg);
+ call = build_call_expr_loc (loc, fn_puts, 1, newarg);
}
else
/* We'd like to arrange to call fputs(string,stdout) here,
@@ -13056,7 +13145,7 @@ fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore,
if (!arg || !validate_arg (arg, POINTER_TYPE))
return NULL_TREE;
if (fn_puts)
- call = build_call_expr (fn_puts, 1, arg);
+ call = build_call_expr_loc (loc, fn_puts, 1, arg);
}
/* If the format specifier was "%c", call __builtin_putchar(arg). */
@@ -13065,13 +13154,13 @@ fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore,
if (!arg || !validate_arg (arg, INTEGER_TYPE))
return NULL_TREE;
if (fn_putchar)
- call = build_call_expr (fn_putchar, 1, arg);
+ call = build_call_expr_loc (loc, fn_putchar, 1, arg);
}
if (!call)
return NULL_TREE;
- return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), call);
+ return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), call);
}
/* Fold a call to the {,v}fprintf{,_unlocked} and __{,v}printf_chk builtins.
@@ -13083,7 +13172,8 @@ fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore,
code of the function to be simplified. */
static tree
-fold_builtin_fprintf (tree fndecl, tree fp, tree fmt, tree arg, bool ignore,
+fold_builtin_fprintf (location_t loc, tree fndecl, tree fp,
+ tree fmt, tree arg, bool ignore,
enum built_in_function fcode)
{
tree fn_fputc, fn_fputs, call = NULL_TREE;
@@ -13142,7 +13232,7 @@ fold_builtin_fprintf (tree fndecl, tree fp, tree fmt, tree arg, bool ignore,
fprintf (fp, string) with fputs (string, fp). The fputs
builtin will take care of special cases like length == 1. */
if (fn_fputs)
- call = build_call_expr (fn_fputs, 2, fmt, fp);
+ call = build_call_expr_loc (loc, fn_fputs, 2, fmt, fp);
}
/* The other optimizations can be done only on the non-va_list variants. */
@@ -13155,7 +13245,7 @@ fold_builtin_fprintf (tree fndecl, tree fp, tree fmt, tree arg, bool ignore,
if (!arg || !validate_arg (arg, POINTER_TYPE))
return NULL_TREE;
if (fn_fputs)
- call = build_call_expr (fn_fputs, 2, arg, fp);
+ call = build_call_expr_loc (loc, fn_fputs, 2, arg, fp);
}
/* If the format specifier was "%c", call __builtin_fputc (arg, fp). */
@@ -13164,12 +13254,12 @@ fold_builtin_fprintf (tree fndecl, tree fp, tree fmt, tree arg, bool ignore,
if (!arg || !validate_arg (arg, INTEGER_TYPE))
return NULL_TREE;
if (fn_fputc)
- call = build_call_expr (fn_fputc, 2, arg, fp);
+ call = build_call_expr_loc (loc, fn_fputc, 2, arg, fp);
}
if (!call)
return NULL_TREE;
- return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), call);
+ return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), call);
}
/* Initialize format string characters in the target charset. */
@@ -13812,6 +13902,7 @@ gimple_rewrite_call_expr (gimple stmt, int skip, tree fndecl, int n, ...)
tree *buffer;
int i, j;
va_list ap;
+ location_t loc = gimple_location (stmt);
buffer = XALLOCAVEC (tree, nargs);
va_start (ap, n);
@@ -13821,7 +13912,7 @@ gimple_rewrite_call_expr (gimple stmt, int skip, tree fndecl, int n, ...)
for (j = skip; j < oldnargs; j++, i++)
buffer[i] = gimple_call_arg (stmt, j);
- return fold (build_call_array (TREE_TYPE (fntype), fn, nargs, buffer));
+ return fold (build_call_array_loc (loc, TREE_TYPE (fntype), fn, nargs, buffer));
}
/* Fold a call STMT to __{,v}sprintf_chk. Return NULL_TREE if
@@ -14000,7 +14091,8 @@ gimple_fold_builtin_snprintf_chk (gimple stmt, tree maxlen,
result of the function call is ignored. */
static tree
-gimple_fold_builtin_varargs (tree fndecl, gimple stmt, bool ignore ATTRIBUTE_UNUSED)
+gimple_fold_builtin_varargs (tree fndecl, gimple stmt,
+ bool ignore ATTRIBUTE_UNUSED)
{
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
tree ret = NULL_TREE;
@@ -14037,6 +14129,7 @@ fold_call_stmt (gimple stmt, bool ignore)
{
tree ret = NULL_TREE;
tree fndecl = gimple_call_fndecl (stmt);
+ location_t loc = gimple_location (stmt);
if (fndecl
&& TREE_CODE (fndecl) == FUNCTION_DECL
&& DECL_BUILT_IN (fndecl)
@@ -14063,7 +14156,7 @@ fold_call_stmt (gimple stmt, bool ignore)
int i;
for (i = 0; i < nargs; i++)
args[i] = gimple_call_arg (stmt, i);
- ret = fold_builtin_n (fndecl, args, nargs, ignore);
+ ret = fold_builtin_n (loc, fndecl, args, nargs, ignore);
}
if (!ret)
ret = gimple_fold_builtin_varargs (fndecl, stmt, ignore);
@@ -14080,7 +14173,7 @@ fold_call_stmt (gimple stmt, bool ignore)
realret = TREE_OPERAND (ret, 0);
if (CAN_HAVE_LOCATION_P (realret)
&& !EXPR_HAS_LOCATION (realret))
- SET_EXPR_LOCATION (realret, gimple_location (stmt));
+ SET_EXPR_LOCATION (realret, loc);
return realret;
}
return ret;
OpenPOWER on IntegriCloud