aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2007-09-17 18:47:15 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2007-09-17 18:47:15 +0000
commit93a85f02f1a82d47efba7f10ea4a12ea2502ba18 (patch)
tree737c1bd28d0703c03d1c89e661c5dabe82dc0f79
parent14f874333a484d2ceca641873ae2aaf41a2f4611 (diff)
downloadgcc-93a85f02f1a82d47efba7f10ea4a12ea2502ba18.zip
gcc-93a85f02f1a82d47efba7f10ea4a12ea2502ba18.tar.gz
gcc-93a85f02f1a82d47efba7f10ea4a12ea2502ba18.tar.bz2
tree-sra.c (maybe_lookup_element_for_expr): Return NULL for variable-sized records too.
* tree-sra.c (maybe_lookup_element_for_expr) <COMPONENT_REF>: Return NULL for variable-sized records too. (sra_walk_expr) <COMPONENT_REF>: Stop at variable-sized records too. From-SVN: r128553
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/tree-sra.c34
2 files changed, 28 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 72ab679..2d4575a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-17 Eric Botcazou <ebotcazou@adacore.com>
+
+ * tree-sra.c (maybe_lookup_element_for_expr) <COMPONENT_REF>: Return
+ NULL for variable-sized records too.
+ (sra_walk_expr) <COMPONENT_REF>: Stop at variable-sized records too.
+
2007-09-17 Tom Tromey <tromey@redhat.com>
* c-decl.c (pushdecl): Don't set DECL_LANG_SPECIFIC.
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 5d69a49..4a3924b 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -636,10 +636,17 @@ maybe_lookup_element_for_expr (tree expr)
break;
case COMPONENT_REF:
- /* Don't look through unions. */
- if (TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) != RECORD_TYPE)
- return NULL;
- child = TREE_OPERAND (expr, 1);
+ {
+ tree type = TREE_TYPE (TREE_OPERAND (expr, 0));
+ /* Don't look through unions. */
+ if (TREE_CODE (type) != RECORD_TYPE)
+ return NULL;
+ /* Neither through variable-sized records. */
+ if (TYPE_SIZE (type) == NULL_TREE
+ || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
+ return NULL;
+ child = TREE_OPERAND (expr, 1);
+ }
break;
case REALPART_EXPR:
@@ -789,14 +796,17 @@ sra_walk_expr (tree *expr_p, block_stmt_iterator *bsi, bool is_output,
break;
case COMPONENT_REF:
- /* A reference to a union member constitutes a reference to the
- entire union. */
- if (TREE_CODE (TREE_TYPE (TREE_OPERAND (inner, 0))) != RECORD_TYPE)
- goto use_all;
- /* ??? See above re non-constant stride. */
- if (TREE_OPERAND (inner, 2))
- goto use_all;
- inner = TREE_OPERAND (inner, 0);
+ {
+ tree type = TREE_TYPE (TREE_OPERAND (inner, 0));
+ /* Don't look through unions. */
+ if (TREE_CODE (type) != RECORD_TYPE)
+ goto use_all;
+ /* Neither through variable-sized records. */
+ if (TYPE_SIZE (type) == NULL_TREE
+ || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
+ goto use_all;
+ inner = TREE_OPERAND (inner, 0);
+ }
break;
case REALPART_EXPR: