From: ebotcazou Date: Wed, 26 May 2010 17:57:30 +0000 (+0000) Subject: * gimple.c (gimple_types_compatible_p): Return 0 for aggregate and X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=895241b460d4ca6822a2d44b6b2dca7e486a2ad4;p=thirdparty%2Fgcc.git * gimple.c (gimple_types_compatible_p): Return 0 for aggregate and 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a6da7120eb5c..476964354033 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-05-26 Eric Botcazou + + * 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 * config/sparc/sparc.h (FUNCTION_VALUE, FUNCTION_OUTGOING_VALUE, diff --git a/gcc/gimple.c b/gcc/gimple.c index 07b91f81dc5b..759caf2e0c32 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 8852b4acf1e8..d8a28db0787f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-05-26 Eric Botcazou + + * gnat.dg/lto10.adb: New test. + * gnat.dg/lto10_pkg.ads: New helper. + 2010-05-26 Kai Tietz * 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 000000000000..647ed0063e7b --- /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 000000000000..9be6a78c9c61 --- /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;