tree.c (build1_stat): Also propagate the TREE_CONSTANT and TREE_INVARIANT flags for...
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 10 Aug 2006 22:13:42 +0000 (22:13 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 10 Aug 2006 22:13:42 +0000 (22:13 +0000)
* tree.c (build1_stat): Also propagate the TREE_CONSTANT and
TREE_INVARIANT flags for a VIEW_CONVERT_EXPR.

From-SVN: r116071

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/specs/static_initializer.ads [new file with mode: 0644]
gcc/tree.c

index 5d6f9d5255a4a5c49a9294acf022f2c75a00f7e1..c42ae6017d531eca9e60d8adbb1ad49046ec988b 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-11  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree.c (build1_stat): Also propagate the TREE_CONSTANT and
+       TREE_INVARIANT flags for a VIEW_CONVERT_EXPR.
+
 2006-08-10  Paul Brook  <paul@codesourcery.com>
 
        * final.c (final_scan_insn): Clear current_insn_predicate before
index f08c34c63efc5f2deb9a2a89995cfdd77f23bb88..44a48940b8911e7d8ea6e0852ab48e5c9b952c9a 100644 (file)
@@ -1,3 +1,7 @@
+2006-08-10  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/specs/static_initializer.ads: New test.
+
 2006-08-10  Paul Brook  <paul@codesourcery.com>
 
        * gcc.target/arm/cond-asm.c: New test.
diff --git a/gcc/testsuite/gnat.dg/specs/static_initializer.ads b/gcc/testsuite/gnat.dg/specs/static_initializer.ads
new file mode 100644 (file)
index 0000000..8755c30
--- /dev/null
@@ -0,0 +1,14 @@
+-- { dg-do compile }
+
+package static_initializer is
+
+  type Vector is array (1 .. 3) of Float;
+  type Arr is array (Integer range 1 .. 3) of Vector;
+
+  Pos : constant Arr := ((0.0, 1.0, 2.0),
+                         (0.5, 1.5, 2.5),
+                         (1.0, 2.0, 4.0));
+
+end;
+
+-- { dg-final { scan-assembler-not "elabs" } }
index dc78ad775af92523ec7a43795a8c4057cd2bc167..efccfb11d9a1e28d53056dfc85f1844694403852 100644 (file)
@@ -2923,11 +2923,11 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL)
       break;
 
     default:
-      if (TREE_CODE_CLASS (code) == tcc_unary
+      if ((TREE_CODE_CLASS (code) == tcc_unary || code == VIEW_CONVERT_EXPR)
          && node && !TYPE_P (node)
          && TREE_CONSTANT (node))
        TREE_CONSTANT (t) = 1;
-      if (TREE_CODE_CLASS (code) == tcc_unary
+      if ((TREE_CODE_CLASS (code) == tcc_unary || code == VIEW_CONVERT_EXPR)
          && node && TREE_INVARIANT (node))
        TREE_INVARIANT (t) = 1;
       if (TREE_CODE_CLASS (code) == tcc_reference