aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2010-05-26 17:57:30 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2010-05-26 17:57:30 +0000
commitc9549072bf0d3db00f8b89e4ed72d63e9eef3549 (patch)
treee7de8d484424021858dfc03cb0ea221d07c05c0b /gcc
parentdb94b0d8594de05c65ace54404d25739965162c7 (diff)
downloadgcc-c9549072bf0d3db00f8b89e4ed72d63e9eef3549.zip
gcc-c9549072bf0d3db00f8b89e4ed72d63e9eef3549.tar.gz
gcc-c9549072bf0d3db00f8b89e4ed72d63e9eef3549.tar.bz2
gimple.c (gimple_types_compatible_p): Return 0 for aggregate and pointer types if they have different alignment or mode.
* gimple.c (gimple_types_compatible_p): Return 0 for aggregate and pointer types if they have different alignment or mode. From-SVN: r159896
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/gimple.c11
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gnat.dg/lto10.adb14
-rw-r--r--gcc/testsuite/gnat.dg/lto10_pkg.ads18
5 files changed, 51 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a6da712..4769643 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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,
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 07b91f8..759caf2 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8852b4a..d8a28db 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..647ed00
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto10.adb
@@ -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
index 0000000..9be6a78
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto10_pkg.ads
@@ -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;