aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wstrict-aliasing-float-ptr-int-obj.c
diff options
context:
space:
mode:
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.c23
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 00000000000..7780fa6fcd6
--- /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-warning "type-punn" } */
+ } else {
+ q = (float*) &y; /* { dg-warning "type-punn" } */
+ }
+
+ *q = 1.0;
+
+ return x;
+
+}