OSDN Git Service

Testsuite changes for new -Wstrict-aliasing=2 option.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / alias-2.c
diff --git a/gcc/testsuite/gcc.dg/alias-2.c b/gcc/testsuite/gcc.dg/alias-2.c
new file mode 100644 (file)
index 0000000..d507416
--- /dev/null
@@ -0,0 +1,16 @@
+// { dg-do compile }
+// { dg-options "-Wstrict-aliasing=2 -fstrict-aliasing" }
+
+struct foo {
+  char c;
+  char d;
+  short s;
+  int i;
+} bar;
+
+int
+sub1 (long long int foobar)
+{
+  struct foo *tmp = (struct foo *) &foobar; // { dg-warning "type-punned pointer might" "" }
+  return tmp->i;
+}