aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.c
diff options
context:
space:
mode:
authorBalaji V. Iyer <balaji.v.iyer@intel.com>2013-06-03 22:28:09 +0000
committerBalaji V. Iyer <bviyer@gcc.gnu.org>2013-06-03 15:28:09 -0700
commit25c229379aa6c0bc8cadd913e014dd9be62453f3 (patch)
tree6714a569c16b57dd993b27c2763c4eb5a607bc3b /gcc/c/c-parser.c
parentedd2564566a0b6e9ca7252b3ac66f346deb31a2f (diff)
downloadgcc-25c229379aa6c0bc8cadd913e014dd9be62453f3.zip
gcc-25c229379aa6c0bc8cadd913e014dd9be62453f3.tar.gz
gcc-25c229379aa6c0bc8cadd913e014dd9be62453f3.tar.bz2
Fixed a bug in expansion of array notations in if-statement conditions.
2013-06-03 Balaji V. Iyer <balaji.v.iyer@intel.com> * c-typeck.c (c_finish_if_stmt): Added a check to see if the rank of the condition of the if-statement matches the rank of else-block and then- block when array notations are used. * c-parser.c (c_parser_declaration_or_fndef): Expanded array notation expression after the entire function body is parsed. (c_parser_expr_no_commas): Delayed creating array notation expressions to the end of function parsing. * c-array-notation.c (fix_conditional_array_notations_1): Expanded the whole if-statement instead of just the condition. (expand_array_notation_exprs): Added MODIFY_EXPR case. 2013-06-03 Balaji V. Iyer <balaji.v.iyer@intel.com> * c-c++-common/cilk-plus/AN/if_test_errors.c (main): New testcase. * c-c++-common/cilk-plus/AN/rank_mismatch.c: Added a '-w' option to dg-option and an header comment. From-SVN: r199628
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r--gcc/c/c-parser.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index b89d8c1..d6a500e 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -1756,6 +1756,8 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
DECL_STRUCT_FUNCTION (current_function_decl)->function_start_locus
= c_parser_peek_token (parser)->location;
fnbody = c_parser_compound_statement (parser);
+ if (flag_enable_cilkplus && contains_array_notation_expr (fnbody))
+ fnbody = expand_array_notation_exprs (fnbody);
if (nested)
{
tree decl = current_function_decl;
@@ -5445,20 +5447,9 @@ c_parser_expr_no_commas (c_parser *parser, struct c_expr *after)
rhs = c_parser_expr_no_commas (parser, NULL);
rhs = default_function_array_read_conversion (exp_location, rhs);
- /* The line below is where the statement has the form:
- A = B, where A and B contain array notation exprs. So this is where
- we handle those. */
- if (flag_enable_cilkplus
- && (contains_array_notation_expr (lhs.value)
- || contains_array_notation_expr (rhs.value)))
- ret.value = build_array_notation_expr (op_location, lhs.value,
- lhs.original_type, code,
- exp_location, rhs.value,
- rhs.original_type);
- else
- ret.value = build_modify_expr (op_location, lhs.value, lhs.original_type,
- code, exp_location, rhs.value,
- rhs.original_type);
+ ret.value = build_modify_expr (op_location, lhs.value, lhs.original_type,
+ code, exp_location, rhs.value,
+ rhs.original_type);
if (code == NOP_EXPR)
ret.original_code = MODIFY_EXPR;
else