diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Sema/uninit-variables.c | 17 | ||||
-rw-r--r-- | test/SemaCXX/uninit-variables.cpp | 6 |
2 files changed, 21 insertions, 2 deletions
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c index 2630b70ec0..4e3d74b3ea 100644 --- a/test/Sema/uninit-variables.c +++ b/test/Sema/uninit-variables.c @@ -33,8 +33,8 @@ int test5() { int test6() { int x; // expected-note{{initialize the variable 'x' to silence this warning}} - x += 2; // expected-warning{{variable 'x' is uninitialized when used here}} - return x; + x += 2; + return x; // expected-warning{{variable 'x' is uninitialized when used here}} } int test7(int y) { @@ -485,3 +485,16 @@ int returns_twice() { } return a; } + +int compound_assign(int *arr, int n) { + int sum; // expected-note {{initialize}} + for (int i = 0; i < n; ++i) + sum += arr[i]; + return sum / n; // expected-warning {{variable 'sum' is uninitialized}} +} + +void compound_assign_2(int n) { + volatile int ignore; + for (int j = 0; j < n; ++j) + ignore += test1(); // ok +} diff --git a/test/SemaCXX/uninit-variables.cpp b/test/SemaCXX/uninit-variables.cpp index eb6428d631..687bfd2638 100644 --- a/test/SemaCXX/uninit-variables.cpp +++ b/test/SemaCXX/uninit-variables.cpp @@ -141,3 +141,9 @@ void test_bitcasts_2() { int y = (float &)x; // expected-warning {{uninitialized when used here}} } +void consume_const_ref(const int &n); +int test_const_ref() { + int n; // expected-note {{variable}} + consume_const_ref(n); + return n; // expected-warning {{uninitialized when used here}} +} |