diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wstrict-aliasing-float-ptr-int-obj.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstrict-aliasing-float-ptr-int-obj.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstrict-aliasing-float-ptr-int-obj.c b/gcc/testsuite/gcc.dg/Wstrict-aliasing-float-ptr-int-obj.c new file mode 100644 index 000000000..b90fb76c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-aliasing-float-ptr-int-obj.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wstrict-aliasing -fstrict-aliasing" } */ + +extern int flag; + +int foo() { + + int x; + int y = 9; + float* q; + float* r; + + if (flag) { + q = (float*) &x; /* { dg-message "initialized" "" { xfail *-*-* } } */ + } else { + q = (float*) &y; /* { dg-message "initialized" "" { xfail *-*-* } } */ + } + + *q = 1.0; /* { dg-warning "does break strict-aliasing" "" { xfail *-*-* } } */ + + return x; + +} |