On 10/29/2015 01:18 PM, Alan Lawrence wrote:
This is in response to https://gcc.gnu.org/ml/gcc/2015-10/msg00097.html, where
Richi points out that CONSTRUCTOR elements are not necessarily ordered.
I wasn't sure of a good naming convention for the new get_ctor_element_at_index,
other suggestions welcome.
gcc/ChangeLog:
* gimple-fold.c (fold_array_ctor_reference): Move searching code to:
* fold-const.c (get_ctor_element_at_index): New.
(fold): Remove binary-search through CONSTRUCTOR, call previous.
* fold-const.h (get_ctor_element_at_index): New.
Code is fine. Some formatting nits though.
---
gcc/fold-const.c | 93 ++++++++++++++++++++++++++++++++++++++++---------------
gcc/fold-const.h | 1 +
gcc/gimple-fold.c | 47 ++--------------------------
3 files changed, 72 insertions(+), 69 deletions(-)
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index de45a2c..5d27b91 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
+
+ FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), cnt, cfield, cval)
+ {
+ /* Array constructor might explicitely set index, or specify range
+ * or leave index NULL meaning that it is next index after previous
+ * one. */
s/explicitely/explicitly/ And remove the '*' from the 2nd and 3rd lines
of the comment.
It looks like get_ctor_element_at_index has numerous formatting
problems. In particular you didn't indent the braces across the board
properly. Also check for tabs vs spaces issues please.
Can you please fix the formatting and comments and repost for a final check?
Thanks,
Jeff