]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* gimple.c (gimple_types_compatible_p): Return 0 for aggregate and
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 May 2010 17:57:30 +0000 (17:57 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 May 2010 17:57:30 +0000 (17:57 +0000)
pointer types if they have different alignment or mode.

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

gcc/ChangeLog
gcc/gimple.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/lto10.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/lto10_pkg.ads [new file with mode: 0644]

index a6da7120eb5cff135d11fdbf08e0ad2b168bb4fc..4769643540339fc5d291406902f8610febcee4d9 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gimple.c (gimple_types_compatible_p): Return 0 for aggregate and
+       pointer types if they have different alignment or mode.
+
 2010-05-26  Anatoly Sokolov  <aesok@post.ru>
 
        * config/sparc/sparc.h (FUNCTION_VALUE, FUNCTION_OUTGOING_VALUE,
index 07b91f81dc5be40b1bb3a3fe66ee018407654b36..759caf2e0c320569db8952e3fb90068e2e7b2242 100644 (file)
@@ -3299,8 +3299,7 @@ gimple_types_compatible_p (tree t1, tree t2)
   if (TREE_CODE (t1) == VOID_TYPE)
     return 1;
 
-  /* For numerical types do some simple checks before doing three
-     hashtable queries.  */
+  /* Do some simple checks before doing three hashtable queries.  */
   if (INTEGRAL_TYPE_P (t1)
       || SCALAR_FLOAT_TYPE_P (t1)
       || FIXED_POINT_TYPE_P (t1)
@@ -3334,6 +3333,14 @@ gimple_types_compatible_p (tree t1, tree t2)
       /* For integral types fall thru to more complex checks.  */
     }
 
+  else if (AGGREGATE_TYPE_P (t1) || POINTER_TYPE_P (t1))
+    {
+      /* Can't be the same type if they have different alignment or mode.  */
+      if (TYPE_ALIGN (t1) != TYPE_ALIGN (t2)
+         || TYPE_MODE (t1) != TYPE_MODE (t2))
+       return 0;
+    }
+
   /* If the hash values of t1 and t2 are different the types can't
      possibly be the same.  This helps keeping the type-pair hashtable
      small, only tracking comparisons for hash collisions.  */
index 8852b4acf1e802128a90d8a6e713b3415093e5a0..d8a28db0787f86755231241a2f116960f16ff137 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-26  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/lto10.adb: New test.
+       * gnat.dg/lto10_pkg.ads: New helper.
+
 2010-05-26  Kai Tietz  <kai.tietz@onevision.com>
 
        * lib/target-supports.exp (check_effective_target_int128): New
diff --git a/gcc/testsuite/gnat.dg/lto10.adb b/gcc/testsuite/gnat.dg/lto10.adb
new file mode 100644 (file)
index 0000000..647ed00
--- /dev/null
@@ -0,0 +1,14 @@
+-- { dg-do run }
+-- { dg-options "-flto" { target lto } }
+
+with Lto10_Pkg; use Lto10_Pkg;
+
+procedure Lto10 is
+   A : Integer := Minus_One;
+   Pos : Position;
+begin
+   Pos := Pix.Pos;
+   if A /= Minus_One then
+      raise Program_Error;
+   end if;
+end;
diff --git a/gcc/testsuite/gnat.dg/lto10_pkg.ads b/gcc/testsuite/gnat.dg/lto10_pkg.ads
new file mode 100644 (file)
index 0000000..9be6a78
--- /dev/null
@@ -0,0 +1,18 @@
+package Lto10_Pkg is
+
+   type U16 is mod 2 ** 16;
+
+   type Position is record
+      X, Y, Z : U16;
+   end record;
+   for Position'Size use 48;
+
+   type Pixel is record
+      Pos : Position;
+   end record;
+   pragma Pack (Pixel);
+
+   Minus_One : Integer := -1;
+   Pix : Pixel := (Pos => (X => 0, Y => 0, Z => 0));
+
+end Lto10_Pkg;