summaryrefslogtreecommitdiff
path: root/gcc/c/c-array-notation.c
diff options
context:
space:
mode:
authorbviyer <bviyer@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-03 22:28:09 +0000
committerbviyer <bviyer@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-03 22:28:09 +0000
commitcc92dddcc1ccf36b35e2533f1b0a0fe418c67144 (patch)
tree6714a569c16b57dd993b27c2763c4eb5a607bc3b /gcc/c/c-array-notation.c
parenteddc63fdd079c88224537f35d257f8c75b618f4a (diff)
downloadgcc-cc92dddcc1ccf36b35e2533f1b0a0fe418c67144.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199628 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c/c-array-notation.c')
-rw-r--r--gcc/c/c-array-notation.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c
index 080746625a6..bcd09224d0c 100644
--- a/gcc/c/c-array-notation.c
+++ b/gcc/c/c-array-notation.c
@@ -1879,7 +1879,7 @@ fix_conditional_array_notations_1 (tree stmt)
if (!find_rank (location, cond, cond, false, &rank))
return error_mark_node;
- extract_array_notation_exprs (cond, false, &array_list);
+ extract_array_notation_exprs (stmt, false, &array_list);
loop_init = push_stmt_list ();
for (ii = 0; ii < vec_safe_length (array_list); ii++)
{
@@ -1899,12 +1899,12 @@ fix_conditional_array_notations_1 (tree stmt)
vec_safe_push (sub_list, array_node);
vec_safe_push (new_var_list, new_var);
add_stmt (builtin_loop);
- replace_array_notations (&cond, false, sub_list, new_var_list);
+ replace_array_notations (&stmt, false, sub_list, new_var_list);
}
}
}
- if (!find_rank (location, cond, cond, true, &rank))
+ if (!find_rank (location, stmt, stmt, true, &rank))
{
pop_stmt_list (loop_init);
return error_mark_node;
@@ -1915,7 +1915,7 @@ fix_conditional_array_notations_1 (tree stmt)
pop_stmt_list (loop_init);
return loop_init;
}
- extract_array_notation_exprs (cond, true, &array_list);
+ extract_array_notation_exprs (stmt, true, &array_list);
if (vec_safe_length (array_list) == 0)
return stmt;
@@ -2765,6 +2765,18 @@ expand_array_notation_exprs (tree t)
expand_array_notation_exprs (*tsi_stmt_ptr (ii_tsi));
}
return t;
+ case MODIFY_EXPR:
+ {
+ location_t loc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) :
+ UNKNOWN_LOCATION;
+ tree lhs = TREE_OPERAND (t, 0);
+ tree rhs = TREE_OPERAND (t, 1);
+ location_t rhs_loc = EXPR_HAS_LOCATION (rhs) ? EXPR_LOCATION (rhs) :
+ UNKNOWN_LOCATION;
+ t = build_array_notation_expr (loc, lhs, TREE_TYPE (lhs), NOP_EXPR,
+ rhs_loc, rhs, TREE_TYPE (rhs));
+ return t;
+ }
case CALL_EXPR:
t = fix_array_notation_call_expr (t);
return t;