re PR middle-end/51782 (-ftree-sra: Missing address-space information leads to wrong)

PR middle-end/51782
	* gcc.target/avr/torture/pr51782-1.c: New test.

From-SVN: r184434
This commit is contained in:
Georg-Johann Lay 2012-02-21 11:54:27 +00:00 committed by Georg-Johann Lay
parent 8540e6e8bd
commit 305406d3e1
2 changed files with 56 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2012-02-21 Georg-Johann Lay <avr@gjlay.de>
PR middle-end/51782
* gcc.target/avr/torture/pr51782-1.c: New test.
2012-02-21 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/52318

View File

@ -0,0 +1,51 @@
/* PR middle-end/51782 */
/* { dg-do run } */
/* { dg-options { "-std=gnu99" } } */
#include <stdlib.h>
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);
}