diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2bbb672a3d4..0fe2f699e57 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-02-21 Georg-Johann Lay + + PR middle-end/51782 + * gcc.target/avr/torture/pr51782-1.c: New test. + 2012-02-21 Jakub Jelinek PR tree-optimization/52318 diff --git a/gcc/testsuite/gcc.target/avr/torture/pr51782-1.c b/gcc/testsuite/gcc.target/avr/torture/pr51782-1.c new file mode 100644 index 00000000000..ff0f9d45fae --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/torture/pr51782-1.c @@ -0,0 +1,51 @@ +/* PR middle-end/51782 */ +/* { dg-do run } */ +/* { dg-options { "-std=gnu99" } } */ + +#include + +struct R { char r; }; +struct RGB { char r,g,b; }; + +__flash const struct R r1 = { 12 }; +__flash const struct RGB r3 = { 23, 56, 78 }; + +char __attribute__((noinline,noclone)) +read1_bug (const __flash struct R *s) +{ + struct R t = *s; + return t.r; +} + +char __attribute__((noinline,noclone)) +read1_ok (const __flash struct R *s) +{ + return s->r; +} + +char __attribute__((noinline,noclone)) +read3_bug (const __flash struct RGB *s) +{ + struct RGB t = *s; + return t.r + t.g + t.b; +} + +char __attribute__((noinline,noclone)) +read3_ok (const __flash struct RGB *s) +{ + return s->r + s->g + s->b; +} + +__flash const struct R * volatile p1 = &r1; +__flash const struct RGB * volatile p3 = &r3; + +int main (void) +{ + if (read1_bug (p1) != read1_ok (p1)) + abort(); + + if (read3_bug (p3) != read3_ok (p3)) + abort(); + + exit (0); +}