diff options
author | bviyer <bviyer@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-25 20:41:21 +0000 |
---|---|---|
committer | bviyer <bviyer@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-06-25 20:41:21 +0000 |
commit | 50acebe0cb70d8a581e5344b599fcf1b4f1d8a73 (patch) | |
tree | d0304bbb6ee06694d451892f81119e01d2141350 /gcc/c-family/array-notation-common.c | |
parent | b16b68598b191e0d093ebe022cf80cfc52c896bb (diff) | |
download | gcc-50acebe0cb70d8a581e5344b599fcf1b4f1d8a73.tar.gz |
Replaced Dynamic arrays with vec trees in Array Notation for C.
gcc/c-family/ChangeLog
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* array-notation-common.c (length_mismatch_in_expr): Changed the
parameter type's from a dynamic array to a vec_tree. Also removed
the size parameters.
* c-common.h (length_mismatch_in_expr_p): Fixed prototype's as per
the change above.
gcc/cp/ChangeLog
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* cp-array-notation.c (cp_length_mismatch_in_expr_p): Remove.
(expand_an_in_modify_expr): Changed a function call from the above
removed function to length_mismatch_in_expr_p.
gcc/c/ChangeLog
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-array-notation.c (make_triplet_val_inv): New function.
(create_cmp_incr): Likewise.
(create_array_refs): Likewise.
(fix_builtin_array_notation_fn): Replaced all mallocs with tree vec.
Also modularized common parts between functions and called the function.
(build_array_notation_expr): Likewise.
(fix_conditional_array_notations_1): Likewise.
(fix_array_notation_expr): Likewise.
(fix_array_notation_call_expr): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200405 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family/array-notation-common.c')
-rw-r--r-- | gcc/c-family/array-notation-common.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/gcc/c-family/array-notation-common.c b/gcc/c-family/array-notation-common.c index 0e2a43132f5..8eab89ba6fb 100644 --- a/gcc/c-family/array-notation-common.c +++ b/gcc/c-family/array-notation-common.c @@ -75,35 +75,37 @@ extract_sec_implicit_index_arg (location_t location, tree fn) return return_int; } -/* Returns true if there is length mismatch among expressions - on the same dimension and on the same side of the equal sign. The - expressions (or ARRAY_NOTATION lengths) are passed in through 2-D array - **LIST where X and Y indicate first and second dimension sizes of LIST, - respectively. */ +/* Returns true if there is a length mismatch among exprssions that are at the + same dimension and one the same side of the equal sign. The Array notation + lengths (LIST->LENGTH) is passed in as a 2D vector of trees. */ bool -length_mismatch_in_expr_p (location_t loc, tree **list, size_t x, size_t y) +length_mismatch_in_expr_p (location_t loc, vec<vec<an_parts> >list) { size_t ii, jj; - tree start = NULL_TREE; - HOST_WIDE_INT l_start, l_node; + tree length = NULL_TREE; + HOST_WIDE_INT l_length, l_node; + + size_t x = list.length (); + size_t y = list[0].length (); + for (jj = 0; jj < y; jj++) { - start = NULL_TREE; + length = NULL_TREE; for (ii = 0; ii < x; ii++) { - if (!start) - start = list[ii][jj]; - else if (TREE_CODE (start) == INTEGER_CST) + if (!length) + length = list[ii][jj].length; + else if (TREE_CODE (length) == INTEGER_CST) { - /* If start is a INTEGER, and list[ii][jj] is an integer then + /* If length is a INTEGER, and list[ii][jj] is an integer then check if they are equal. If they are not equal then return true. */ - if (TREE_CODE (list[ii][jj]) == INTEGER_CST) + if (TREE_CODE (list[ii][jj].length) == INTEGER_CST) { - l_node = int_cst_value (list[ii][jj]); - l_start = int_cst_value (start); - if (absu_hwi (l_start) != absu_hwi (l_node)) + l_node = int_cst_value (list[ii][jj].length); + l_length = int_cst_value (length); + if (absu_hwi (l_length) != absu_hwi (l_node)) { error_at (loc, "length mismatch in expression"); return true; @@ -111,9 +113,9 @@ length_mismatch_in_expr_p (location_t loc, tree **list, size_t x, size_t y) } } else - /* We set the start node as the current node just in case it turns + /* We set the length node as the current node just in case it turns out to be an integer. */ - start = list[ii][jj]; + length = list[ii][jj].length; } } return false; |