#include "system.h"
#include "coretypes.h"
#include "tm.h"
+#include "rtl.h"
#include "tree.h"
#include "langhooks.h"
#include "c-tree.h"
#include "c-lang.h"
+#include "tm_p.h"
#include "flags.h"
#include "output.h"
#include "expr.h"
#include "toplev.h"
#include "intl.h"
+#include "ggc.h"
#include "target.h"
#include "tree-iterator.h"
+#include "gimple.h"
#include "tree-flow.h"
/* Possible cases of implicit bad conversions. Used to select
return exp;
}
\f
-/* Look up COMPONENT in a structure or union TYPE.
+/* Look up COMPONENT in a structure or union DECL.
If the component name is not found, returns NULL_TREE. Otherwise,
the return value is a TREE_LIST, with each TREE_VALUE a FIELD_DECL
unions, the list steps down the chain to the component. */
static tree
-lookup_field (tree type, tree component)
+lookup_field (tree decl, tree component)
{
+ tree type = TREE_TYPE (decl);
tree field;
/* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers
if (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
|| TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
{
- tree anon = lookup_field (TREE_TYPE (field), component);
+ tree anon = lookup_field (field, component);
if (anon)
return tree_cons (NULL_TREE, field, anon);
&& (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
|| TREE_CODE (TREE_TYPE (field)) == UNION_TYPE))
{
- tree anon = lookup_field (TREE_TYPE (field), component);
+ tree anon = lookup_field (field, component);
if (anon)
return tree_cons (NULL_TREE, field, anon);
return error_mark_node;
}
- field = lookup_field (type, component);
+ field = lookup_field (datum, component);
if (!field)
{
void
set_init_label (tree fieldname, struct obstack * braced_init_obstack)
{
- tree field;
+ tree tail;
if (set_designator (0, braced_init_obstack))
return;
return;
}
- field = lookup_field (constructor_type, fieldname);
+ for (tail = TYPE_FIELDS (constructor_type); tail;
+ tail = TREE_CHAIN (tail))
+ {
+ if (DECL_NAME (tail) == fieldname)
+ break;
+ }
- if (field == 0)
+ if (tail == 0)
error ("unknown field %qE specified in initializer", fieldname);
else
- do
- {
- constructor_fields = TREE_VALUE (field);
- designator_depth++;
- designator_erroneous = 0;
- if (constructor_range_stack)
- push_range_stack (NULL_TREE, braced_init_obstack);
- field = TREE_CHAIN (field);
- if (field)
- {
- if (set_designator (0, braced_init_obstack))
- return;
- }
- }
- while (field != NULL_TREE);
+ {
+ constructor_fields = tail;
+ designator_depth++;
+ designator_erroneous = 0;
+ if (constructor_range_stack)
+ push_range_stack (NULL_TREE, braced_init_obstack);
+ }
}
\f
/* Add a new initializer to the tree of pending initializers. PURPOSE
tree
c_process_expr_stmt (location_t loc, tree expr)
{
- tree exprv;
-
if (!expr)
return NULL_TREE;
&& warn_unused_value)
emit_side_effect_warnings (loc, expr);
- exprv = expr;
- while (TREE_CODE (exprv) == COMPOUND_EXPR)
- exprv = TREE_OPERAND (exprv, 1);
- if (DECL_P (exprv) || handled_component_p (exprv))
- mark_exp_read (exprv);
+ if (DECL_P (expr) || handled_component_p (expr))
+ mark_exp_read (expr);
/* If the expression is not of a type to which we cannot assign a line
number, wrap the thing in a no-op NOP_EXPR. */
if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
{
- mark_exp_read (expr);
expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
SET_EXPR_LOCATION (expr, loc);
}
&& (code1 == INTEGER_TYPE || code1 == REAL_TYPE
|| code1 == FIXED_POINT_TYPE || code1 == COMPLEX_TYPE))
short_compare = 1;
- else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
- {
- if (TREE_CODE (op0) == ADDR_EXPR
- && decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)))
- {
- if (code == EQ_EXPR)
- warning_at (location,
- OPT_Waddress,
- "the comparison will always evaluate as %<false%> "
- "for the address of %qD will never be NULL",
- TREE_OPERAND (op0, 0));
- else
- warning_at (location,
- OPT_Waddress,
- "the comparison will always evaluate as %<true%> "
- "for the address of %qD will never be NULL",
- TREE_OPERAND (op0, 0));
- }
- result_type = type0;
- }
- else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
- {
- if (TREE_CODE (op1) == ADDR_EXPR
- && decl_with_nonnull_addr_p (TREE_OPERAND (op1, 0)))
- {
- if (code == EQ_EXPR)
- warning_at (location,
- OPT_Waddress,
- "the comparison will always evaluate as %<false%> "
- "for the address of %qD will never be NULL",
- TREE_OPERAND (op1, 0));
- else
- warning_at (location,
- OPT_Waddress,
- "the comparison will always evaluate as %<true%> "
- "for the address of %qD will never be NULL",
- TREE_OPERAND (op1, 0));
- }
- result_type = type1;
- }
else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
{
tree tt0 = TREE_TYPE (type0);
and both must be object or both incomplete. */
if (comp_target_types (location, type0, type1))
result_type = common_pointer_type (type0, type1);
+ else if (null_pointer_constant_p (orig_op0))
+ result_type = type1;
+ else if (null_pointer_constant_p (orig_op1))
+ result_type = type0;
else if (!addr_space_superset (as0, as1, &as_common))
{
error_at (location, "comparison of pointers to "
(build_qualified_type (void_type_node, qual));
}
}
+ else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
+ {
+ if (TREE_CODE (op0) == ADDR_EXPR
+ && decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)))
+ warning_at (location,
+ OPT_Waddress, "the address of %qD will never be NULL",
+ TREE_OPERAND (op0, 0));
+ result_type = type0;
+ }
+ else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
+ {
+ if (TREE_CODE (op1) == ADDR_EXPR
+ && decl_with_nonnull_addr_p (TREE_OPERAND (op1, 0)))
+ warning_at (location,
+ OPT_Waddress, "the address of %qD will never be NULL",
+ TREE_OPERAND (op1, 0));
+ result_type = type1;
+ }
else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
{
result_type = type0;
else if (TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
pedwarn (location, OPT_pedantic, "ISO C forbids "
"ordered comparisons of pointers to functions");
- else if (null_pointer_constant_p (orig_op0)
- || null_pointer_constant_p (orig_op1))
- warning_at (location, OPT_Wextra,
- "ordered comparison of pointer with null pointer");
-
}
else if (!addr_space_superset (as0, as1, &as_common))
{
"ordered comparison of pointer with integer zero");
else if (extra_warnings)
warning_at (location, OPT_Wextra,
- "ordered comparison of pointer with integer zero");
+ "ordered comparison of pointer with integer zero");
}
else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
{
result_type = type1;
- if (pedantic)
- pedwarn (location, OPT_pedantic,
- "ordered comparison of pointer with integer zero");
- else if (extra_warnings)
- warning_at (location, OPT_Wextra,
- "ordered comparison of pointer with integer zero");
+ pedwarn (location, OPT_pedantic,
+ "ordered comparison of pointer with integer zero");
}
else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
{