diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r-- | gcc/testsuite/gcc.dg/uninit-15.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/uninit-16.c | 22 |
2 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/uninit-15.c b/gcc/testsuite/gcc.dg/uninit-15.c new file mode 100644 index 00000000000..dee7a3b211c --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-15.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +inline int foo (int i) +{ + if (i) return 1; /* { dg-warning "is used uninitialized" } */ + return 0; +} + +void baz(); + +void bar() +{ + int j; /* { dg-message "was declared here" } */ + for (; foo(j); ++j) + baz(); +} diff --git a/gcc/testsuite/gcc.dg/uninit-16.c b/gcc/testsuite/gcc.dg/uninit-16.c new file mode 100644 index 00000000000..aefb5e5f7d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-16.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int foo, bar; + +void decode_reloc(int reloc, int *is_alt) +{ + if (reloc >= 20) + *is_alt = 1; + else if (reloc >= 10) + *is_alt = 0; +} + +void testfunc() +{ + int alt_reloc; + + decode_reloc(foo, &alt_reloc); + + if (alt_reloc) /* { dg-warning "may be used uninitialized" } */ + bar = 42; +} |