]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
expr.c (expand_expr): When checking promoted value, use DECL_MODE (exp) and not mode.
authorJakub Jelinek <jakub@redhat.com>
Wed, 5 Dec 2001 14:15:37 +0000 (15:15 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 5 Dec 2001 14:15:37 +0000 (15:15 +0100)
* expr.c (expand_expr): When checking promoted value, use
DECL_MODE (exp) and not mode.

* g++.dg/other/anon-union.C: New test.

From-SVN: r47674

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/anon-union.C [new file with mode: 0644]

index e2485c52f2247b25f93a1d33853c8acd698673a6..c3d9d389e924213fa8f6000d9e951b5a9d460efb 100644 (file)
@@ -1,3 +1,8 @@
+2001-12-05  Jakub Jelinek  <jakub@redhat.com>
+
+       * expr.c (expand_expr): When checking promoted value, use
+       DECL_MODE (exp) and not mode.
+
 2001-12-05  Jakub Jelinek  <jakub@redhat.com>
 
        * c-typeck.c (output_init_element): Call digest_init
index af36b3b5820fff038176f5c9edd0d52b42c5b6db..e988c4c42b23be07ac2f2199879c5ec7019748ea 100644 (file)
@@ -6452,7 +6452,7 @@ expand_expr (exp, target, tmode, modifier)
         but mark it so that we know that it was already extended.  */
 
       if (GET_CODE (DECL_RTL (exp)) == REG
-         && GET_MODE (DECL_RTL (exp)) != mode)
+         && GET_MODE (DECL_RTL (exp)) != DECL_MODE (exp))
        {
          /* Get the signedness used for this variable.  Ensure we get the
             same mode we got when the variable was declared.  */
index 56b2f089d40c19a5ce6034fa2eea41b801bd3f72..5dace7b75821b10081e1e222e4178c482ae9d426 100644 (file)
@@ -4,6 +4,8 @@
 
        * gcc.dg/noncompile/20011025-1.c: New test.
 
+       * g++.dg/other/anon-union.C: New test.
+
 2001-12-04  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * gcc.c-torture/execute/20000722-1.x,
diff --git a/gcc/testsuite/g++.dg/other/anon-union.C b/gcc/testsuite/g++.dg/other/anon-union.C
new file mode 100644 (file)
index 0000000..51598bf
--- /dev/null
@@ -0,0 +1,22 @@
+// { dg-do compile }
+// { dg-options -O2 }
+
+int foo ();
+double bar (void)
+{
+  union
+  {
+    char a[8];
+    double b;
+  };
+
+  a[0] = foo ();
+  a[1] = foo ();
+  a[2] = foo ();
+  a[3] = foo ();
+  a[4] = foo ();
+  a[5] = foo ();
+  a[6] = foo ();
+  a[7] = foo ();
+  return b;
+}