aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2012-08-19 10:33:04 +0000
committerDimitry Andric <dim@FreeBSD.org>2012-08-19 10:33:04 +0000
commit657bc3d9848e3be92029b2416031340988cd0111 (patch)
tree5b9c2fa9d79942fbdce3d618e37e27c18263af9a /test/SemaCXX
parent56d91b49b13fe55c918afbda19f6165b5fbff87a (diff)
downloadsrc-657bc3d9848e3be92029b2416031340988cd0111.tar.gz
src-657bc3d9848e3be92029b2416031340988cd0111.zip
Vendor import of clang trunk r162107:vendor/clang/clang-trunk-r162107
Notes
Notes: svn path=/vendor/clang/dist/; revision=239392 svn path=/vendor/clang/clang-trunk-r162107/; revision=239393; tag=vendor/clang/clang-trunk-r162107
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/convert-to-bool.cpp3
-rw-r--r--test/SemaCXX/pragma-pack.cpp23
-rw-r--r--test/SemaCXX/references.cpp2
-rw-r--r--test/SemaCXX/uninitialized.cpp81
-rw-r--r--test/SemaCXX/warn-thread-safety-parsing.cpp10
5 files changed, 116 insertions, 3 deletions
diff --git a/test/SemaCXX/convert-to-bool.cpp b/test/SemaCXX/convert-to-bool.cpp
index c9a355549fdf..b52f11c93d39 100644
--- a/test/SemaCXX/convert-to-bool.cpp
+++ b/test/SemaCXX/convert-to-bool.cpp
@@ -62,6 +62,5 @@ struct C {
void test_copy_init_conversions(C c) {
A &a = c; // expected-error{{no viable conversion from 'C' to 'A'}}
- B &b = b; // okay
+ B &b = c; // okay
}
-
diff --git a/test/SemaCXX/pragma-pack.cpp b/test/SemaCXX/pragma-pack.cpp
index 1bc738b087a9..5c1d5c6c82af 100644
--- a/test/SemaCXX/pragma-pack.cpp
+++ b/test/SemaCXX/pragma-pack.cpp
@@ -32,3 +32,26 @@ struct Sub : virtual Base {
int check[sizeof(Sub) == 13 ? 1 : -1];
}
+
+namespace llvm_support_endian {
+
+template<typename, bool> struct X;
+
+#pragma pack(push)
+#pragma pack(1)
+template<typename T> struct X<T, true> {
+ T t;
+};
+#pragma pack(pop)
+
+#pragma pack(push)
+#pragma pack(2)
+template<> struct X<long double, true> {
+ long double c;
+};
+#pragma pack(pop)
+
+int check1[__alignof(X<int, true>) == 1 ? 1 : -1];
+int check2[__alignof(X<long double, true>) == 2 ? 1 : -1];
+
+}
diff --git a/test/SemaCXX/references.cpp b/test/SemaCXX/references.cpp
index 70d3799a0ea5..028c6909210e 100644
--- a/test/SemaCXX/references.cpp
+++ b/test/SemaCXX/references.cpp
@@ -136,4 +136,4 @@ namespace PR8608 {
}
// The following crashed trying to recursively evaluate the LValue.
-const int &do_not_crash = do_not_crash;
+const int &do_not_crash = do_not_crash; // expected-warning{{variable 'do_not_crash' is uninitialized when used within its own initialization}}
diff --git a/test/SemaCXX/uninitialized.cpp b/test/SemaCXX/uninitialized.cpp
index 13d287bf1af6..385548b51cca 100644
--- a/test/SemaCXX/uninitialized.cpp
+++ b/test/SemaCXX/uninitialized.cpp
@@ -316,3 +316,84 @@ namespace {
G(char (*)[8]) : f3(new F(f3->*ptr)) {} // expected-warning {{field is uninitialized when used here}}
};
}
+
+namespace statics {
+ static int a = a; // no-warning: used to signal intended lack of initialization.
+ static int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}}
+ static int c = (c + c); // expected-warning 2{{variable 'c' is uninitialized when used within its own initialization}}
+ static int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}}
+ static int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}}
+
+ // Thes don't warn as they don't require the value.
+ static int g = sizeof(g);
+ int gg = g; // Silence unneeded warning
+ static void* ptr = &ptr;
+ static int h = bar(&h);
+ static int i = boo(i);
+ static int j = far(j);
+ static int k = __alignof__(k);
+
+ static int l = k ? l : l; // expected-warning 2{{variable 'l' is uninitialized when used within its own initialization}}
+ static int m = 1 + (k ? m : m); // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}}
+ static int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}}
+
+ void test() {
+ static int a = a; // no-warning: used to signal intended lack of initialization.
+ static int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}}
+ static int c = (c + c); // expected-warning 2{{variable 'c' is uninitialized when used within its own initialization}}
+ static int d = ({ d + d ;}); // expected-warning 2{{variable 'd' is uninitialized when used within its own initialization}}
+ static int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}}
+ static int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}}
+
+ // Thes don't warn as they don't require the value.
+ static int g = sizeof(g);
+ static void* ptr = &ptr;
+ static int h = bar(&h);
+ static int i = boo(i);
+ static int j = far(j);
+ static int k = __alignof__(k);
+
+ static int l = k ? l : l; // expected-warning 2{{variable 'l' is uninitialized when used within its own initialization}}
+ static int m = 1 + (k ? m : m); // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}}
+ static int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}}
+ for (;;) {
+ static int a = a; // no-warning: used to signal intended lack of initialization.
+ static int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}}
+ static int c = (c + c); // expected-warning 2{{variable 'c' is uninitialized when used within its own initialization}}
+ static int d = ({ d + d ;}); // expected-warning 2{{variable 'd' is uninitialized when used within its own initialization}}
+ static int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}}
+ static int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}}
+
+ // Thes don't warn as they don't require the value.
+ static int g = sizeof(g);
+ static void* ptr = &ptr;
+ static int h = bar(&h);
+ static int i = boo(i);
+ static int j = far(j);
+ static int k = __alignof__(k);
+
+ static int l = k ? l : l; // expected-warning 2{{variable 'l' is uninitialized when used within its own initialization}}
+ static int m = 1 + (k ? m : m); // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}}
+ static int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}}
+ }
+ }
+}
+
+namespace references {
+ int &a = a; // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+
+ struct S {
+ S() : a(a) {} // expected-warning{{field is uninitialized when used here}}
+ int &a;
+ };
+
+ void f() {
+ int &a = a; // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+ }
+
+ struct T {
+ T() : a(b), b(a) {} // FIXME: Warn here.
+ int &a, &b;
+ int &c = c; // FIXME: Warn here.
+ };
+}
diff --git a/test/SemaCXX/warn-thread-safety-parsing.cpp b/test/SemaCXX/warn-thread-safety-parsing.cpp
index 3f8a7359088d..8aa6a91a9d2d 100644
--- a/test/SemaCXX/warn-thread-safety-parsing.cpp
+++ b/test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1429,4 +1429,14 @@ class Foo {
}
+namespace InvalidDeclTest {
+
+class Foo { };
+namespace {
+void Foo::bar(Mutex* mu) LOCKS_EXCLUDED(mu) { } // \
+ // expected-error {{cannot define or redeclare 'bar' here because namespace '' does not enclose namespace 'Foo'}} \
+ // expected-warning {{attribute locks_excluded ignored, because it is not attached to a declaration}}
+}
+
+} // end namespace InvalidDeclTest