aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/wtr-union-init-1.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2000-08-23 16:13:47 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2000-08-23 16:13:47 +0000
commit8a451613436b38938d577b0f2d0b8896b3141893 (patch)
tree5e8a157ec041c96ec106a6df77176615b5972056 /gcc/testsuite/gcc.dg/wtr-union-init-1.c
parent23d168774ed0113530edf9b65beab12241890870 (diff)
downloadgcc-8a451613436b38938d577b0f2d0b8896b3141893.zip
gcc-8a451613436b38938d577b0f2d0b8896b3141893.tar.gz
gcc-8a451613436b38938d577b0f2d0b8896b3141893.tar.bz2
tr-warn4.c, [...]: New tests.
* gcc.dg/cpp/tr-warn4.c, gcc.dg/cpp/tr-warn5.c, gcc.dg/wtr-aggr-init-1.c, gcc.dg/wtr-escape-1.c, gcc.dg/wtr-int-type-1.c, gcc.dg/wtr-static-1.c, gcc.dg/wtr-strcat-1.c, gcc.dg/wtr-switch-1.c, gcc.dg/wtr-unary-plus-1.c, gcc.dg/wtr-union-init-1.c: New tests. From-SVN: r35913
Diffstat (limited to 'gcc/testsuite/gcc.dg/wtr-union-init-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/wtr-union-init-1.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/wtr-union-init-1.c b/gcc/testsuite/gcc.dg/wtr-union-init-1.c
new file mode 100644
index 0000000..1f00069
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/wtr-union-init-1.c
@@ -0,0 +1,25 @@
+/* Test for -Wtraditional warnings on union initialization.
+ Note, gcc should omit these warnings in system header files.
+ By Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 8/22/2000. */
+/* { dg-do compile } */
+/* { dg-options "-Wtraditional" } */
+
+union foo
+{
+ int i;
+ long l;
+};
+
+void
+testfunc (void)
+{
+ /* Note we only warn for non-zero initializers. */
+ static union foo f1 = { 0 };
+ static union foo f2 = { 1 }; /* { dg-warning "traditional C rejects initialization of unions" "initialization of unions" } */
+
+#line 21 "sys-header.h" 3
+/* We are in system headers now, no -Wtraditional warnings should issue. */
+
+ static union foo f3 = { 0 };
+ static union foo f4 = { 1 };
+}