]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2007-01-05 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Jan 2007 21:04:23 +0000 (21:04 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Jan 2007 21:04:23 +0000 (21:04 +0000)
PR middle-end/27826
* tree.c (get_narrower): Do not construct COMPONENT_REFs
with mismatched types.  Instead explicitly build a
conversion NOP_EXPR.

* g++.dg/opt/pr27826.C: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120498 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr27826.C [new file with mode: 0644]
gcc/tree.c

index 92925123a4a498950ac1e2e67e8c883703bc5323..45de0c4bca482b278bc65f3fe32164c5ea12457e 100644 (file)
@@ -1,3 +1,10 @@
+2007-01-05  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/27826
+       * tree.c (get_narrower): Do not construct COMPONENT_REFs
+       with mismatched types.  Instead explicitly build a
+       conversion NOP_EXPR.
+
 2007-01-05  Ian Lance Taylor  <iant@google.com>
 
        * c-common.c (decl_with_nonnull_addr_p): New function.
index 8856b7e2ff62cb53f5869d1d849cffc4a3e11580..817846a9fb820415e1bdbbff0d6d877845d7553e 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-05  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/27826
+       * g++.dg/opt/pr27826.C: New testcase.
+
 2007-01-05  Ian Lance Taylor  <iant@google.com>
 
        * gcc.dg/Walways-true-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/opt/pr27826.C b/gcc/testsuite/g++.dg/opt/pr27826.C
new file mode 100644 (file)
index 0000000..5e40f17
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+struct Geometry
+{
+        int type:16;
+};
+struct Geometry get() {};
+int f()
+{
+        struct Geometry test;
+        return get().type == test.type;
+}
+
index 5abd6f345f3ca28c85545dfb91352866797090ad..71d221ee486cfa2accfb8065e27238be6d91faa4 100644 (file)
@@ -5989,12 +5989,10 @@ get_narrower (tree op, int *unsignedp_ptr)
        {
          if (first)
            uns = DECL_UNSIGNED (TREE_OPERAND (op, 1));
-         win = build3 (COMPONENT_REF, type, TREE_OPERAND (op, 0),
-                       TREE_OPERAND (op, 1), NULL_TREE);
-         TREE_SIDE_EFFECTS (win) = TREE_SIDE_EFFECTS (op);
-         TREE_THIS_VOLATILE (win) = TREE_THIS_VOLATILE (op);
+         win = fold_convert (type, op);
        }
     }
+
   *unsignedp_ptr = uns;
   return win;
 }