summaryrefslogtreecommitdiff
path: root/gcc/c-parser.c
diff options
context:
space:
mode:
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>2008-09-23 14:55:14 +0000
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>2008-09-23 14:55:14 +0000
commit8e70fb09031df0afb5a38f40975bb174a8574ebd (patch)
tree21c7a88d82936ace208bcdd02d4ba68c691c6cf7 /gcc/c-parser.c
parente3154a0596af0c9ed26c9be292fbd75fe4f40c64 (diff)
downloadgcc-8e70fb09031df0afb5a38f40975bb174a8574ebd.tar.gz
* c-tree.h: Add argument to c_objc_common_truthvalue_conversion,
parser_build_binary_op. * c-decl.c (build_enumerator): Pass location to build_binary_op. * c-typeck.c (build_array_ref): Same. (parser_build_unary_op): New location argument. (pointer_diff): Pass location to build_binary_op, c_objc_common_truthvalue_conversion. (build_modify_expr): Same. (build_unary_op): New location argument. (build_binary_op): New location argument. (c_objc_common_truthvalue_conversion): Pass location to c_*common_truthvalue_conversion. * c-convert.c (convert): Same. * c-common.c (binary_op_error): New location argument. (pointer_int_sum): Pass location to build_binary_op. (c_common_truthvalue_conversion): New location argument. (warn_for_sign_compare): Same. * c-common.h: Add location argument to c_common_truthvalue_conversion, binary_op_error, build_binary_op, warn_for_sign_compare. * c-parser.c (c_parser_condition): Pass location to c_*common_truthvalue_conversion. (c_parser_conditional_expression): Save condition's location and pass it on down. (c_parser_binary_expression): Same, but for the binary operator's location. (c_parser_omp_for_loop): Pass location to c_objc_common_truthvalue_conversion. objc/ * objc-act.c (next_sjlj_build_enter_and_setjmp): Call c_common_truthvalue_conversion with location. (next_sjlj_build_catch_list): Same. (next_sjlj_build_try_catch_finally): Same. testsuite/ * gcc.dg/Walways-true-1.c: Test column numbers. * gcc.dg/c90-const-expr-5.c: Same. * gcc.dg/compare4.c: Same. * gcc.dg/Werror-1.c: Same. cp/ * typeck.c (build_array_ref): Pass location to cp_build_binary_op. (get_member_function_from_ptrfunc): Same. (build_x_binary_op): Same. (build_binary_op): Same. (cp_build_binary_op): New location argument. (pointer_diff): Pass location to cp_build_binary_op. (cp_truthvalue_conversion): Pass location to build_binary_op. (convert_ptrmem): Pass location to cp_build_binary_op. (cp_build_modify_expr): Same. (build_ptrmemfunc): Same. * init.c (expand_cleanup_for_base): Pass location to c_common_truthvalue_conversion. (build_new_1): Pass location to cp_build_binary_op. (build_vec_delete_1): Pass location to *build_binary_op, c_common_truthvalue_conversion. (build_vec_init): Same. (build_delete): Same. * decl.c (compute_array_index_type): Same. * call.c (build_new_op): Same. * rtti.c (build_dynamic_cast_1): Same. * cp-tree.h: Add argument to cp_build_binary_op. * semantics.c (handle_omp_for_class_iterator): Pass location to *build_binary_op, c_common_truthvalue_conversion. * decl2.c (get_guard_cond): Same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140598 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r--gcc/c-parser.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index 43ef655495e..4222f41e19f 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -3805,7 +3805,7 @@ c_parser_condition (c_parser *parser)
tree cond;
loc = c_parser_peek_token (parser)->location;
cond = c_objc_common_truthvalue_conversion
- (c_parser_expression_conv (parser).value);
+ (loc, c_parser_expression_conv (parser).value);
if (CAN_HAVE_LOCATION_P (cond))
SET_EXPR_LOCATION (cond, loc);
if (warn_sequence_point)
@@ -4426,8 +4426,13 @@ static struct c_expr
c_parser_conditional_expression (c_parser *parser, struct c_expr *after)
{
struct c_expr cond, exp1, exp2, ret;
+ location_t cond_loc;
+
gcc_assert (!after || c_dialect_objc ());
+
+ cond_loc = c_parser_peek_token (parser)->location;
cond = c_parser_binary_expression (parser, after);
+
if (c_parser_next_token_is_not (parser, CPP_QUERY))
return cond;
cond = default_function_array_conversion (cond);
@@ -4438,14 +4443,14 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after)
"ISO C forbids omitting the middle term of a ?: expression");
/* Make sure first operand is calculated only once. */
exp1.value = save_expr (default_conversion (cond.value));
- cond.value = c_objc_common_truthvalue_conversion (exp1.value);
+ cond.value = c_objc_common_truthvalue_conversion (cond_loc, exp1.value);
skip_evaluation += cond.value == truthvalue_true_node;
}
else
{
cond.value
= c_objc_common_truthvalue_conversion
- (default_conversion (cond.value));
+ (cond_loc, default_conversion (cond.value));
skip_evaluation += cond.value == truthvalue_false_node;
exp1 = c_parser_expression_conv (parser);
skip_evaluation += ((cond.value == truthvalue_true_node)
@@ -4570,6 +4575,8 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
enum tree_code op;
} stack[NUM_PRECS];
int sp;
+ /* Location of the binary operator. */
+ location_t binary_loc;
#define POP \
do { \
switch (stack[sp].op) \
@@ -4587,7 +4594,8 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
= default_function_array_conversion (stack[sp - 1].expr); \
stack[sp].expr \
= default_function_array_conversion (stack[sp].expr); \
- stack[sp - 1].expr = parser_build_binary_op (stack[sp].op, \
+ stack[sp - 1].expr = parser_build_binary_op (binary_loc, \
+ stack[sp].op, \
stack[sp - 1].expr, \
stack[sp].expr); \
sp--; \
@@ -4681,6 +4689,7 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
expression. */
goto out;
}
+ binary_loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
while (oprec <= stack[sp].prec)
POP;
@@ -4690,14 +4699,14 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after)
stack[sp].expr
= default_function_array_conversion (stack[sp].expr);
stack[sp].expr.value = c_objc_common_truthvalue_conversion
- (default_conversion (stack[sp].expr.value));
+ (binary_loc, default_conversion (stack[sp].expr.value));
skip_evaluation += stack[sp].expr.value == truthvalue_false_node;
break;
case TRUTH_ORIF_EXPR:
stack[sp].expr
= default_function_array_conversion (stack[sp].expr);
stack[sp].expr.value = c_objc_common_truthvalue_conversion
- (default_conversion (stack[sp].expr.value));
+ (binary_loc, default_conversion (stack[sp].expr.value));
skip_evaluation += stack[sp].expr.value == truthvalue_true_node;
break;
default:
@@ -7602,7 +7611,7 @@ c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
if (c_parser_next_token_is_not (parser, CPP_SEMICOLON))
{
cond = c_parser_expression_conv (parser).value;
- cond = c_objc_common_truthvalue_conversion (cond);
+ cond = c_objc_common_truthvalue_conversion (input_location, cond);
if (CAN_HAVE_LOCATION_P (cond))
SET_EXPR_LOCATION (cond, input_location);
}