summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/uninit-9.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>1999-03-14 20:19:03 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>1999-03-14 20:19:03 +0000
commit56688b583fb2176268ae0ed21f76b60eb11a6d90 (patch)
treed4f02d9031d19efbec979e7d6a51a1192f2d52ea /gcc/testsuite/gcc.dg/uninit-9.c
parenta249d2b311d1df441da3ad24a17f4e2c9c574976 (diff)
downloadgcc-56688b583fb2176268ae0ed21f76b60eb11a6d90.tar.gz
More tests for uninitialized variable warnings
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@25770 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/uninit-9.c')
-rw-r--r--gcc/testsuite/gcc.dg/uninit-9.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/uninit-9.c b/gcc/testsuite/gcc.dg/uninit-9.c
new file mode 100644
index 00000000000..8b439a4512d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-9.c
@@ -0,0 +1,41 @@
+/* Spurious uninitialized variable warnings. Slight variant on the
+ documented case, inspired by reg-stack.c:record_asm_reg_life. */
+
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+struct foo
+{
+ int type;
+ struct foo *car;
+ struct foo *cdr;
+ char *data;
+ int data2;
+};
+
+extern void use(struct foo *);
+
+#define CLOBBER 6
+#define PARALLEL 3
+
+void
+func(struct foo *list, int count)
+{
+ int n_clobbers = 0;
+ int i;
+ struct foo **clob_list; /* { dg-bogus "clob_list" "uninitialized variable warning" { xfail *-*-* } } */
+
+ if(list[0].type == PARALLEL)
+ {
+ clob_list = alloca(count * sizeof(struct foo *));
+
+ for(i = 1; i < count; i++)
+ {
+ if(list[i].type == CLOBBER)
+ clob_list[n_clobbers++] = &list[i];
+ }
+ }
+
+ for(i = 0; i < n_clobbers; i++)
+ use(clob_list[i]);
+}