summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/uninit-variables.c
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-01-21 19:41:41 +0000
committerTed Kremenek <kremenek@apple.com>2011-01-21 19:41:41 +0000
commit39fa05634287190fa5898715dc66ac68ce5028ef (patch)
tree013592f1b6250b363089e10c095e9d9d222c61fc /clang/test/Sema/uninit-variables.c
parenta834200dbe3ca1164198d8b79454c0f21c1c5a0d (diff)
downloadbcm5719-llvm-39fa05634287190fa5898715dc66ac68ce5028ef.tar.gz
bcm5719-llvm-39fa05634287190fa5898715dc66ac68ce5028ef.zip
Enhance -Wuninitialized-experimental diagnostics
to issue the warning at an uninitialized variable's declaration, but to issue notes at possible uninitialized uses (which could be multiple). llvm-svn: 123994
Diffstat (limited to 'clang/test/Sema/uninit-variables.c')
-rw-r--r--clang/test/Sema/uninit-variables.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/clang/test/Sema/uninit-variables.c b/clang/test/Sema/uninit-variables.c
index 7ac225f5a33..62fcda019a4 100644
--- a/clang/test/Sema/uninit-variables.c
+++ b/clang/test/Sema/uninit-variables.c
@@ -1,8 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -Wuninitialized-experimental -fsyntax-only %s -verify
int test1() {
- int x;
- return x; // expected-warning{{use of uninitialized variable 'x'}}
+ int x; // expected-warning{{use of uninitialized variable 'x'}}
+ return x; // expected-note{{variable 'x' is possibly uninitialized when used here}}
}
int test2() {
@@ -17,28 +17,28 @@ int test3() {
}
int test4() {
- int x;
- ++x; // expected-warning{{use of uninitialized variable 'x'}}
+ int x; // expected-warning{{use of uninitialized variable 'x'}}
+ ++x; // expected-note{{variable 'x' is possibly uninitialized when used here}}
return x;
}
int test5() {
- int x, y;
- x = y; // expected-warning{{use of uninitialized variable 'y'}}
+ int x, y; // expected-warning{{use of uninitialized variable 'y'}}
+ x = y; // expected-note{{variable 'y' is possibly uninitialized when used here}}
return x;
}
int test6() {
- int x;
- x += 2; // expected-warning{{use of uninitialized variable 'x'}}
+ int x; // expected-warning{{use of uninitialized variable 'x'}}
+ x += 2; // expected-note{{variable 'x' is possibly uninitialized when used here}}
return x;
}
int test7(int y) {
- int x;
+ int x; // expected-warning{{use of uninitialized variable 'x'}}
if (y)
x = 1;
- return x; // expected-warning{{use of uninitialized variable 'x'}}
+ return x; // expected-note{{variable 'x' is possibly uninitialized when used here}}
}
int test8(int y) {
@@ -51,33 +51,33 @@ int test8(int y) {
}
int test9(int n) {
- int x;
+ int x; // expected-warning{{use of uninitialized variable 'x'}}
for (unsigned i = 0 ; i < n; ++i) {
if (i == n - 1)
break;
- x = 1;
+ x = 1;
}
- return x; // expected-warning{{use of uninitialized variable 'x'}}
+ return x; // expected-note{{variable 'x' is possibly uninitialized when used here}}
}
int test10(unsigned n) {
- int x;
+ int x; // expected-warning{{use of uninitialized variable 'x'}}
for (unsigned i = 0 ; i < n; ++i) {
x = 1;
}
- return x; // expected-warning{{use of uninitialized variable 'x'}}
+ return x; // expected-note{{variable 'x' is possibly uninitialized when used here}}
}
int test11(unsigned n) {
- int x;
+ int x; // expected-warning{{use of uninitialized variable 'x'}}
for (unsigned i = 0 ; i <= n; ++i) {
x = 1;
}
- return x; // expected-warning{{use of uninitialized variable 'x'}}
+ return x; //expected-note{{variable 'x' is possibly uninitialized when used here}}
}
void test12(unsigned n) {
- for (unsigned i ; n ; ++i) ; // expected-warning{{use of uninitialized variable 'i'}}
+ for (unsigned i ; n ; ++i) ; // expected-warning{{use of uninitialized variable 'i'}} expected-note{{variable 'i' is possibly uninitialized when used here}}}
}
int test13() {
@@ -92,7 +92,7 @@ void test14() {
}
void test15() {
- int x = x; // expected-warning{{use of uninitialized variable 'x'}}
+ int x = x; // expected-warning{{use of uninitialized variable 'x'}} expected-note{{variable 'x' is possibly uninitialized when used here}}
}
// Don't warn in the following example; shows dataflow confluence.
@@ -106,8 +106,8 @@ void test16() {
void test17() {
// Don't warn multiple times about the same uninitialized variable
// along the same path.
- int *x;
- *x = 1; // expected-warning{{use of uninitialized variable 'x'}}
+ int *x; // expected-warning{{use of uninitialized variable 'x'}}
+ *x = 1; // expected-note{{variable 'x' is possibly uninitialized when used here}}
*x = 1; // no-warning
}
@@ -130,16 +130,16 @@ int test19() {
}
int test20() {
- int z;
+ int z; // expected-warning{{use of uninitialized variable 'z'}}
if ((test19_aux1() + test19_aux2() && test19_aux1()) || test19_aux3(&z))
- return z; // expected-warning{{use of uninitialized variable 'z'}}
+ return z; // expected-note{{variable 'z' is possibly uninitialized when used here}}
return 0;
}
int test21(int x, int y) {
- int z;
+ int z; // expected-warning{{use of uninitialized variable 'z'}}
if ((x && y) || test19_aux3(&z) || test19_aux2())
- return z; // expected-warning{{use of uninitialized variable 'z'}}
+ return z; // expected-note{{variable 'z' is possibly uninitialized when used here}}
return 0;
}
@@ -162,11 +162,11 @@ int test23() {
// conditionals. This possibly can be handled by making the CFG itself
// represent such control-dependencies, but it is a niche case.
int test24(int flag) {
- unsigned val;
+ unsigned val; // expected-warning{{use of uninitialized variable 'val'}}
if (flag)
val = 1;
if (!flag)
val = 1;
- return val; // expected-warning{{use of uninitialized variable 'val'}}
+ return val; // expected-note{{variable 'val' is possibly uninitialized when used here}}
}
OpenPOWER on IntegriCloud