From 1a13360e95779bc9b462a4c8c00dfe8e782f8dbd Mon Sep 17 00:00:00 2001 From: Olivier Hainque Date: Fri, 27 Jun 2008 07:35:33 +0000 Subject: [PATCH] gimplify.c (gimplify_modify_expr_to_memset): Assert our documented assumptions. 2008-06-26 Olivier Hainque gcc/ * gimplify.c (gimplify_modify_expr_to_memset): Assert our documented assumptions. testsuite/ * gnat.dg/aligned_vla.adb: New test. From-SVN: r137171 --- gcc/ChangeLog | 5 +++++ gcc/gimplify.c | 13 ++++++++++++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/aligned_vla.adb | 23 +++++++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gnat.dg/aligned_vla.adb diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d16198ef85b..35b4818e795 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-06-26 Olivier Hainque + + * gimplify.c (gimplify_modify_expr_to_memset): Assert our + documented assumptions. + 2008-06-26 H.J. Lu * dwarf2out.c: Remove trailing white spaces. Break long line diff --git a/gcc/gimplify.c b/gcc/gimplify.c index bf81bb0c09a..799ccbee52c 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2809,8 +2809,19 @@ gimplify_modify_expr_to_memcpy (tree *expr_p, tree size, bool want_value) static enum gimplify_status gimplify_modify_expr_to_memset (tree *expr_p, tree size, bool want_value) { - tree t, to, to_ptr; + tree t, from, to, to_ptr; + /* Assert our assumptions, to abort instead of producing wrong code + silently if they are not met. Beware that the RHS CONSTRUCTOR might + not be immediately exposed. */ + from = GENERIC_TREE_OPERAND (*expr_p, 1); + if (TREE_CODE (from) == WITH_SIZE_EXPR) + from = TREE_OPERAND (from, 0); + + gcc_assert (TREE_CODE (from) == CONSTRUCTOR + && VEC_empty (constructor_elt, CONSTRUCTOR_ELTS (from))); + + /* Now proceed. */ to = GENERIC_TREE_OPERAND (*expr_p, 0); to_ptr = build_fold_addr_expr (to); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 475416283eb..ed8f15bd6e4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-06-27 Olivier Hainque + + * gnat.dg/aligned_vla.adb: New test. + 2008-06-26 Joseph Myers * gcc.dg/inline-32.c, gcc.dg/inline-32a.c: New tests. diff --git a/gcc/testsuite/gnat.dg/aligned_vla.adb b/gcc/testsuite/gnat.dg/aligned_vla.adb new file mode 100644 index 00000000000..bd3eb7158e5 --- /dev/null +++ b/gcc/testsuite/gnat.dg/aligned_vla.adb @@ -0,0 +1,23 @@ +-- { dg-do run } + +procedure Aligned_Vla is + + type Table is array (Integer range <>) of Integer; + for Table'Alignment use Long_Float'Alignment; + + K : constant := 1; + Konstants : Table (1 .. 4) := (others => K); + + procedure Check_Copy (Len : Integer) is + My_Konstants : Table (1 .. Len) := Konstants (1 .. 1 + Len - 1); + begin + for I in My_Konstants'Range loop + if My_Konstants (I) /= K then + raise Program_Error; + end if; + end loop; + end; + +begin + Check_Copy (Len => 4); +end;