diff options
author | hainque <hainque@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-06-24 12:47:48 +0000 |
---|---|---|
committer | hainque <hainque@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-06-24 12:47:48 +0000 |
commit | 9c530f258696c34161fcbe4f9e04cc7db73b2529 (patch) | |
tree | b0b48b70fe5bdb5192ddb541aa32d97ef613a126 /gcc/testsuite/gnat.dg | |
parent | 939e12ab242727fcb18f43693da9b82f4a2464cc (diff) | |
download | gcc-9c530f258696c34161fcbe4f9e04cc7db73b2529.tar.gz |
* gimplify.c (gimplify_scalar_mode_aggregate_compare): New function.
(gimplify_expr): Use it for tcc_comparison of operands of non BLKmode
aggregate types.
* tree-ssa-loop-im.c (for_each_index): Handle ARRAY_RANGE_REF as
ARRAY_REF, so have the callback called for the low bound expression.
* gnat.dg/scalar_mode_agg_compare_loop.adb: New test.
* gnat.dg/scalar_mode_agg_compare.adb: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114963 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r-- | gcc/testsuite/gnat.dg/scalar_mode_agg_compare.adb | 25 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/scalar_mode_agg_compare_loop.adb | 18 |
2 files changed, 43 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/scalar_mode_agg_compare.adb b/gcc/testsuite/gnat.dg/scalar_mode_agg_compare.adb new file mode 100644 index 00000000000..ff373464282 --- /dev/null +++ b/gcc/testsuite/gnat.dg/scalar_mode_agg_compare.adb @@ -0,0 +1,25 @@ +-- { dg-do run } + +procedure Scalar_Mode_Agg_Compare is + + type Point is record + Mapped : Boolean; + Tag : String (1 .. 2); -- HImode + end record; + pragma Pack (Point); -- Tag possibly at bitpos 1 + + function My_Point return Point is + begin + return (Mapped => True, Tag => "XX"); + end; + + A, B : Point := My_Point; +begin + -- The comparison below should find the two Tag fields equal and not + -- attempt to take their address, which might not be byte aligned. + + if A.Tag /= B.Tag then + raise Program_Error; + end if; +end; + diff --git a/gcc/testsuite/gnat.dg/scalar_mode_agg_compare_loop.adb b/gcc/testsuite/gnat.dg/scalar_mode_agg_compare_loop.adb new file mode 100644 index 00000000000..9bafb4d29bb --- /dev/null +++ b/gcc/testsuite/gnat.dg/scalar_mode_agg_compare_loop.adb @@ -0,0 +1,18 @@ + +-- { dg-do compile } +-- { dg-options "-O2 -gnatp" } + +function Scalar_Mode_Agg_Compare_Loop return Boolean is + S : constant String (1 .. 4) := "ABCD"; + F : constant Natural := S'First; + L : constant Natural := S'Last; +begin + for J in F .. L - 1 loop + if S (F .. F) = "X" or (J <= L - 2 and S (J .. J + 1) = "YY") then + return True; + end if; + end loop; + + return False; +end; + |