summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-20 05:35:17 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-20 05:35:17 +0000
commit6b351cc8c497c4ed9d296b55b424341f20b56f92 (patch)
tree8bcbc6cc30a2f9d6253007a662393cfed258713a /gcc/c-common.c
parentd0df232358778b869142e628e5e736fc7515f5ab (diff)
downloadgcc-6b351cc8c497c4ed9d296b55b424341f20b56f92.tar.gz
2009-07-20 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 149800 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@149801 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c134
1 files changed, 39 insertions, 95 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 20dac6b2ef4..328e0fdae8e 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -598,6 +598,8 @@ const struct c_common_resword c_common_reswords[] =
{ "__is_enum", RID_IS_ENUM, D_CXXONLY },
{ "__is_pod", RID_IS_POD, D_CXXONLY },
{ "__is_polymorphic", RID_IS_POLYMORPHIC, D_CXXONLY },
+ { "__is_standard_layout", RID_IS_STD_LAYOUT, D_CXXONLY },
+ { "__is_trivial", RID_IS_TRIVIAL, D_CXXONLY },
{ "__is_union", RID_IS_UNION, D_CXXONLY },
{ "__imag", RID_IMAGPART, 0 },
{ "__imag__", RID_IMAGPART, 0 },
@@ -1084,6 +1086,7 @@ c_fully_fold (tree expr, bool in_init, bool *maybe_const)
tree eptype = NULL_TREE;
bool dummy = true;
bool maybe_const_itself = true;
+ location_t loc = EXPR_LOCATION (expr);
/* This function is not relevant to C++ because C++ folds while
parsing, and may need changes to be correct for C++ when C++
@@ -1101,7 +1104,7 @@ c_fully_fold (tree expr, bool in_init, bool *maybe_const)
ret = c_fully_fold_internal (expr, in_init, maybe_const,
&maybe_const_itself);
if (eptype)
- ret = fold_convert (eptype, ret);
+ ret = fold_convert_loc (loc, eptype, ret);
*maybe_const &= maybe_const_itself;
return ret;
}
@@ -1298,8 +1301,8 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
op1 = decl_constant_value_for_optimization (op1);
if (op0 != orig_op0 || op1 != orig_op1 || in_init)
ret = in_init
- ? fold_build2_initializer (code, TREE_TYPE (expr), op0, op1)
- : fold_build2 (code, TREE_TYPE (expr), op0, op1);
+ ? fold_build2_initializer_loc (loc, code, TREE_TYPE (expr), op0, op1)
+ : fold_build2_loc (loc, code, TREE_TYPE (expr), op0, op1);
else
ret = fold (expr);
goto out;
@@ -1324,8 +1327,8 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
op0 = decl_constant_value_for_optimization (op0);
if (op0 != orig_op0 || in_init)
ret = in_init
- ? fold_build1_initializer (code, TREE_TYPE (expr), op0)
- : fold_build1 (code, TREE_TYPE (expr), op0);
+ ? fold_build1_initializer_loc (loc, code, TREE_TYPE (expr), op0)
+ : fold_build1_loc (loc, code, TREE_TYPE (expr), op0);
else
ret = fold (expr);
if (code == INDIRECT_REF
@@ -1348,8 +1351,8 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
op1 = c_fully_fold_internal (op1, in_init, &op1_const, &op1_const_self);
if (op0 != orig_op0 || op1 != orig_op1 || in_init)
ret = in_init
- ? fold_build2_initializer (code, TREE_TYPE (expr), op0, op1)
- : fold_build2 (code, TREE_TYPE (expr), op0, op1);
+ ? fold_build2_initializer_loc (loc, code, TREE_TYPE (expr), op0, op1)
+ : fold_build2_loc (loc, code, TREE_TYPE (expr), op0, op1);
else
ret = fold (expr);
*maybe_const_operands &= op0_const;
@@ -1377,7 +1380,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
op1 = c_fully_fold_internal (op1, in_init, &op1_const, &op1_const_self);
op2 = c_fully_fold_internal (op2, in_init, &op2_const, &op2_const_self);
if (op0 != orig_op0 || op1 != orig_op1 || op2 != orig_op2)
- ret = fold_build3 (code, TREE_TYPE (expr), op0, op1, op2);
+ ret = fold_build3_loc (loc, code, TREE_TYPE (expr), op0, op1, op2);
else
ret = fold (expr);
*maybe_const_operands &= op0_const;
@@ -1618,7 +1621,8 @@ warn_logical_operator (location_t location, enum tree_code code, tree type,
if (lhs && rhs && operand_equal_p (lhs, rhs, 0)
&& merge_ranges (&in_p, &low, &high, in0_p, low0, high0,
in1_p, low1, high1)
- && 0 != (tem = build_range_check (type, lhs, in_p, low, high)))
+ && 0 != (tem = build_range_check (UNKNOWN_LOCATION,
+ type, lhs, in_p, low, high)))
{
if (TREE_CODE (tem) != INTEGER_CST)
return;
@@ -3656,7 +3660,8 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
of pointer PTROP and integer INTOP. */
tree
-pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
+pointer_int_sum (location_t loc, enum tree_code resultcode,
+ tree ptrop, tree intop)
{
tree size_exp, ret;
@@ -3665,19 +3670,19 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)
{
- pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
+ pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
"pointer of type %<void *%> used in arithmetic");
size_exp = integer_one_node;
}
else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE)
{
- pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
+ pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
"pointer to a function used in arithmetic");
size_exp = integer_one_node;
}
else if (TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE)
{
- pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
+ pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith,
"pointer to member function used in arithmetic");
size_exp = integer_one_node;
}
@@ -3732,15 +3737,15 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
Do this multiplication as signed, then convert to the appropriate
type for the pointer operation. */
intop = convert (sizetype,
- build_binary_op (EXPR_LOCATION (intop),
+ build_binary_op (loc,
MULT_EXPR, intop,
convert (TREE_TYPE (intop), size_exp), 1));
/* Create the sum or difference. */
if (resultcode == MINUS_EXPR)
- intop = fold_build1 (NEGATE_EXPR, sizetype, intop);
+ intop = fold_build1_loc (loc, NEGATE_EXPR, sizetype, intop);
- ret = fold_build2 (POINTER_PLUS_EXPR, result_type, ptrop, intop);
+ ret = fold_build2_loc (loc, POINTER_PLUS_EXPR, result_type, ptrop, intop);
fold_undefer_and_ignore_overflow_warnings ();
@@ -3923,7 +3928,7 @@ c_common_truthvalue_conversion (location_t location, tree expr)
/* Distribute the conversion into the arms of a COND_EXPR. */
if (c_dialect_cxx ())
{
- expr = fold_build3 (COND_EXPR, truthvalue_type_node,
+ expr = fold_build3_loc (location, COND_EXPR, truthvalue_type_node,
TREE_OPERAND (expr, 0),
c_common_truthvalue_conversion (location,
TREE_OPERAND (expr,
@@ -4288,9 +4293,9 @@ c_sizeof_or_alignof_type (location_t loc,
{
if (is_sizeof)
/* Convert in case a char is more than one unit. */
- value = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
- size_int (TYPE_PRECISION (char_type_node)
- / BITS_PER_UNIT));
+ value = size_binop_loc (loc, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
+ size_int (TYPE_PRECISION (char_type_node)
+ / BITS_PER_UNIT));
else
value = size_int (TYPE_ALIGN_UNIT (type));
}
@@ -4299,7 +4304,7 @@ c_sizeof_or_alignof_type (location_t loc,
TYPE_IS_SIZETYPE means that certain things (like overflow) will
never happen. However, this node should really have type
`size_t', which is just a typedef for an ordinary integer type. */
- value = fold_convert (size_type_node, value);
+ value = fold_convert_loc (loc, size_type_node, value);
gcc_assert (!TYPE_IS_SIZETYPE (TREE_TYPE (value)));
return value;
@@ -4350,7 +4355,7 @@ c_alignof_expr (location_t loc, tree expr)
else
return c_alignof (loc, TREE_TYPE (expr));
- return fold_convert (size_type_node, t);
+ return fold_convert_loc (loc, size_type_node, t);
}
/* Handle C and C++ default attributes. */
@@ -5626,11 +5631,11 @@ boolean_increment (enum tree_code code, tree arg)
break;
case PREDECREMENT_EXPR:
val = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg,
- invert_truthvalue (arg));
+ invert_truthvalue_loc (input_location, arg));
break;
case POSTDECREMENT_EXPR:
val = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg,
- invert_truthvalue (arg));
+ invert_truthvalue_loc (input_location, arg));
arg = save_expr (arg);
val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), val, arg);
val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), arg, val);
@@ -8221,69 +8226,6 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level,
return ret;
}
-/* Walk a gimplified function and warn for functions whose return value is
- ignored and attribute((warn_unused_result)) is set. This is done before
- inlining, so we don't have to worry about that. */
-
-void
-c_warn_unused_result (gimple_seq seq)
-{
- tree fdecl, ftype;
- gimple_stmt_iterator i;
-
- for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
- {
- gimple g = gsi_stmt (i);
-
- switch (gimple_code (g))
- {
- case GIMPLE_BIND:
- c_warn_unused_result (gimple_bind_body (g));
- break;
- case GIMPLE_TRY:
- c_warn_unused_result (gimple_try_eval (g));
- c_warn_unused_result (gimple_try_cleanup (g));
- break;
- case GIMPLE_CATCH:
- c_warn_unused_result (gimple_catch_handler (g));
- break;
- case GIMPLE_EH_FILTER:
- c_warn_unused_result (gimple_eh_filter_failure (g));
- break;
-
- case GIMPLE_CALL:
- if (gimple_call_lhs (g))
- break;
-
- /* This is a naked call, as opposed to a GIMPLE_CALL with an
- LHS. All calls whose value is ignored should be
- represented like this. Look for the attribute. */
- fdecl = gimple_call_fndecl (g);
- ftype = TREE_TYPE (TREE_TYPE (gimple_call_fn (g)));
-
- if (lookup_attribute ("warn_unused_result", TYPE_ATTRIBUTES (ftype)))
- {
- location_t loc = gimple_location (g);
-
- if (fdecl)
- warning_at (loc, OPT_Wunused_result,
- "ignoring return value of %qD, "
- "declared with attribute warn_unused_result",
- fdecl);
- else
- warning_at (loc, OPT_Wunused_result,
- "ignoring return value of function "
- "declared with attribute warn_unused_result");
- }
- break;
-
- default:
- /* Not a container, not a call, or a call whose value is used. */
- break;
- }
- }
-}
-
/* Convert a character from the host to the target execution character
set. cpplib handles this, mostly. */
@@ -8355,9 +8297,10 @@ fold_offsetof_1 (tree expr, tree stop_ref)
"member %qD", t);
return error_mark_node;
}
- off = size_binop (PLUS_EXPR, DECL_FIELD_OFFSET (t),
- size_int (tree_low_cst (DECL_FIELD_BIT_OFFSET (t), 1)
- / BITS_PER_UNIT));
+ off = size_binop_loc (input_location, PLUS_EXPR, DECL_FIELD_OFFSET (t),
+ size_int (tree_low_cst (DECL_FIELD_BIT_OFFSET (t),
+ 1)
+ / BITS_PER_UNIT));
break;
case ARRAY_REF:
@@ -8369,7 +8312,7 @@ fold_offsetof_1 (tree expr, tree stop_ref)
if (TREE_CODE (t) == INTEGER_CST && tree_int_cst_sgn (t) < 0)
{
code = MINUS_EXPR;
- t = fold_build1 (NEGATE_EXPR, TREE_TYPE (t), t);
+ t = fold_build1_loc (input_location, NEGATE_EXPR, TREE_TYPE (t), t);
}
t = convert (sizetype, t);
off = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (TREE_TYPE (expr)), t);
@@ -8462,9 +8405,9 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default)
bool fold_p = false;
if (VEC_index (constructor_elt, v, 0)->index)
- maxindex = fold_convert (sizetype,
- VEC_index (constructor_elt,
- v, 0)->index);
+ maxindex = fold_convert_loc (input_location, sizetype,
+ VEC_index (constructor_elt,
+ v, 0)->index);
curindex = maxindex;
for (cnt = 1;
@@ -8478,7 +8421,8 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default)
{
if (fold_p)
curindex = fold_convert (sizetype, curindex);
- curindex = size_binop (PLUS_EXPR, curindex, size_one_node);
+ curindex = size_binop (PLUS_EXPR, curindex,
+ size_one_node);
}
if (tree_int_cst_lt (maxindex, curindex))
maxindex = curindex, fold_p = curfold_p;