summaryrefslogtreecommitdiff
path: root/test/SemaCXX/uninit-variables.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2011-10-20 21:14:49 +0000
committerDimitry Andric <dim@FreeBSD.org>2011-10-20 21:14:49 +0000
commit36981b17ed939300f6f8fc2355a255f711fcef71 (patch)
treeee2483e98b09cac943dc93a6969d83ca737ff139 /test/SemaCXX/uninit-variables.cpp
parent180abc3db9ae3b4fc63cd65b15697e6ffcc8a657 (diff)
Notes
Diffstat (limited to 'test/SemaCXX/uninit-variables.cpp')
-rw-r--r--test/SemaCXX/uninit-variables.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/test/SemaCXX/uninit-variables.cpp b/test/SemaCXX/uninit-variables.cpp
index a0180e3d3a150..358a5723563fc 100644
--- a/test/SemaCXX/uninit-variables.cpp
+++ b/test/SemaCXX/uninit-variables.cpp
@@ -26,7 +26,7 @@ void unevaluated_tests() {
// Warn for glvalue arguments to typeid whose type is polymorphic.
struct A { virtual ~A() {} };
void polymorphic_test() {
- A *a; // expected-note{{declared here}} expected-note{{add initialization}}
+ A *a; // expected-note{{initialize the variable 'a' to silence this warning}}
(void)typeid(*a); // expected-warning{{variable 'a' is uninitialized when used here }}
}
@@ -50,7 +50,7 @@ unsigned test3_b() {
return x; // no-warning
}
unsigned test3_c() {
- unsigned x; // expected-note{{declared here}} expected-note{{add initialization}}
+ unsigned x; // expected-note{{initialize the variable 'x' to silence this warning}}
const bool flag = false;
if (flag && (x = test3_aux()) == 0) {
x = 1;
@@ -66,6 +66,16 @@ test4_A test4() {
return a; // expected-warning{{variable 'a' is uninitialized when used here}}
}
+// Test variables getting invalidated by function calls with reference arguments
+// *AND* there are multiple invalidated arguments.
+void test5_aux(int &, int &);
+
+int test5() {
+ int x, y;
+ test5_aux(x, y);
+ return x + y; // no-warning
+}
+
// This test previously crashed Sema.
class Rdar9188004A {
public:
@@ -108,4 +118,26 @@ void RDar9251392() {
}
}
+// Test handling of "no-op" casts.
+void test_noop_cast()
+{
+ int x = 1;
+ int y = (int&)x; // no-warning
+}
+
+void test_noop_cast2() {
+ int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+ int y = (int&)x; // expected-warning {{uninitialized when used here}}
+}
+
+// Test handling of bit casts.
+void test_bitcasts() {
+ int x = 1;
+ int y = (float &)x; // no-warning
+}
+
+void test_bitcasts_2() {
+ int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+ int y = (float &)x; // expected-warning {{uninitialized when used here}}
+}