int o = std::move(o); // expected-warning {{variable 'o' is uninitialized when used within its own initialization}}
const int p = std::move(p); // expected-warning {{variable 'p' is uninitialized when used within its own initialization}}
int q = moved(std::move(q)); // expected-warning {{variable 'q' is uninitialized when used within its own initialization}}
+int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}}
+int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}}
+int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}}
void test_stuff () {
int a = a; // no-warning: used to signal intended lack of initialization.
int o = std::move(o); // expected-warning {{variable 'o' is uninitialized when used within its own initialization}}
const int p = std::move(p); // expected-warning {{variable 'p' is uninitialized when used within its own initialization}}
int q = moved(std::move(q)); // expected-warning {{variable 'q' is uninitialized when used within its own initialization}}
+ int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}}
+ int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}}
+ int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}}
for (;;) {
int a = a; // no-warning: used to signal intended lack of initialization.
int o = std::move(o); // expected-warning {{variable 'o' is uninitialized when used within its own initialization}}
const int p = std::move(p); // expected-warning {{variable 'p' is uninitialized when used within its own initialization}}
int q = moved(std::move(q)); // expected-warning {{variable 'q' is uninitialized when used within its own initialization}}
+ int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}}
+ int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}}
+ int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}}
}
}
A a32 = moveA(std::move(a32)); // expected-warning {{variable 'a32' is uninitialized when used within its own initialization}}
A a33 = A(std::move(a33)); // expected-warning {{variable 'a33' is uninitialized when used within its own initialization}}
A a34(std::move(a34)); // expected-warning {{variable 'a34' is uninitialized when used within its own initialization}}
+ A a35 = std::move(x ? a34 : (37, a35)); // expected-warning {{variable 'a35' is uninitialized when used within its own initialization}}
}
bool x;
A a32 = moveA(std::move(a32)); // expected-warning {{variable 'a32' is uninitialized when used within its own initialization}}
A a33 = A(std::move(a33)); // expected-warning {{variable 'a33' is uninitialized when used within its own initialization}}
A a34(std::move(a34)); // expected-warning {{variable 'a34' is uninitialized when used within its own initialization}}
+A a35 = std::move(x ? a34 : (37, a35)); // expected-warning {{variable 'a35' is uninitialized when used within its own initialization}}
struct B {
// POD struct.
int x;
B* getPtrB(int *x) { return 0; };
B* getPtrB(B **b) { return 0; };
-void setupB() {
+void setupB(bool x) {
B b1;
B b2(b1);
B b3 = { 5, &b3.x };
B b21 = std::move(b21); // expected-warning {{variable 'b21' is uninitialized when used within its own initialization}}
B b22 = moveB(std::move(b22)); // expected-warning {{variable 'b22' is uninitialized when used within its own initialization}}
B b23 = B(std::move(b23)); // expected-warning {{variable 'b23' is uninitialized when used within its own initialization}}
+ B b24 = std::move(x ? b23 : (18, b24)); // expected-warning {{variable 'b24' is uninitialized when used within its own initialization}}
}
B b1;
B b21 = std::move(b21); // expected-warning {{variable 'b21' is uninitialized when used within its own initialization}}
B b22 = moveB(std::move(b22)); // expected-warning {{variable 'b22' is uninitialized when used within its own initialization}}
B b23 = B(std::move(b23)); // expected-warning {{variable 'b23' is uninitialized when used within its own initialization}}
+B b24 = std::move(x ? b23 : (18, b24)); // expected-warning {{variable 'b24' is uninitialized when used within its own initialization}}
// Also test similar constructs in a field's initializer.
struct S {
E(char (*)[12]) : a((b + c, c, a)) {} // expected-warning {{field 'a' is uninitialized when used here}}
E(char (*)[13]) : a((a, a, a, a)) {} // expected-warning {{field 'a' is uninitialized when used here}}
E(char (*)[14]) : a((b, c, c)) {}
+ E(char (*)[15]) : a(b ?: a) {} // expected-warning {{field 'a' is uninitialized when used here}}
+ E(char (*)[16]) : a(a ?: b) {} // expected-warning {{field 'a' is uninitialized when used here}}
};
struct F {
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}}
+ static int o = std::move(o); // expected-warning {{variable 'o' is uninitialized when used within its own initialization}}
+ static const int p = std::move(p); // expected-warning {{variable 'p' is uninitialized when used within its own initialization}}
+ static int q = moved(std::move(q)); // expected-warning {{variable 'q' is uninitialized when used within its own initialization}}
+ static int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}}
+ static int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}}
+ static int t = t ?: s; // expected-warning {{variable 't' 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 l = k ? l : l; // expected-warning 2{{static variable 'l' is suspiciously used within its own initialization}}
static int m = 1 + (k ? m : m); // expected-warning 2{{static variable 'm' is suspiciously used within its own initialization}}
static int n = -n; // expected-warning {{static variable 'n' is suspiciously used within its own initialization}}
+ static int o = std::move(o); // expected-warning {{static variable 'o' is suspiciously used within its own initialization}}
+ static const int p = std::move(p); // expected-warning {{static variable 'p' is suspiciously used within its own initialization}}
+ static int q = moved(std::move(q)); // expected-warning {{static variable 'q' is suspiciously used within its own initialization}}
+ static int r = std::move((p ? q : (18, r))); // expected-warning {{static variable 'r' is suspiciously used within its own initialization}}
+ static int s = r ?: s; // expected-warning {{static variable 's' is suspiciously used within its own initialization}}
+ static int t = t ?: s; // expected-warning {{static variable 't' is suspiciously 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 {{static variable 'b' is suspiciously used within its own initialization}}
static int l = k ? l : l; // expected-warning 2{{static variable 'l' is suspiciously used within its own initialization}}
static int m = 1 + (k ? m : m); // expected-warning 2{{static variable 'm' is suspiciously used within its own initialization}}
static int n = -n; // expected-warning {{static variable 'n' is suspiciously used within its own initialization}}
+ static int o = std::move(o); // expected-warning {{static variable 'o' is suspiciously used within its own initialization}}
+ static const int p = std::move(p); // expected-warning {{static variable 'p' is suspiciously used within its own initialization}}
+ static int q = moved(std::move(q)); // expected-warning {{static variable 'q' is suspiciously used within its own initialization}}
+ static int r = std::move((p ? q : (18, r))); // expected-warning {{static variable 'r' is suspiciously used within its own initialization}}
+ static int s = r ?: s; // expected-warning {{static variable 's' is suspiciously used within its own initialization}}
+ static int t = t ?: s; // expected-warning {{static variable 't' is suspiciously used within its own initialization}}
}
}
}
int &b(b); // expected-warning{{reference 'b' is not yet bound to a value when used within its own initialization}}
int &c = a ? b : c; // expected-warning{{reference 'c' is not yet bound to a value when used within its own initialization}}
int &d{d}; // expected-warning{{reference 'd' is not yet bound to a value when used within its own initialization}}
+ int &e = d ?: e; // expected-warning{{reference 'e' is not yet bound to a value when used within its own initialization}}
+ int &f = f ?: d; // expected-warning{{reference 'f' is not yet bound to a value when used within its own initialization}}
struct S {
S() : a(a) {} // expected-warning{{reference 'a' is not yet bound to a value when used here}}
int &a;
};
- void f() {
+ void test() {
int &a = a; // expected-warning{{reference 'a' is not yet bound to a value when used within its own initialization}}
int &b(b); // expected-warning{{reference 'b' is not yet bound to a value when used within its own initialization}}
int &c = a ? b : c; // expected-warning{{reference 'c' is not yet bound to a value when used within its own initialization}}
}
namespace record_fields {
+ bool x;
struct A {
A() {}
A get();
B(char (*)[10]) : a(std::move(a)) {} // expected-warning {{uninitialized}}
B(char (*)[11]) : a(A(std::move(a))) {} // expected-warning {{uninitialized}}
B(char (*)[12]) : a(rref(std::move(a))) {} // expected-warning {{uninitialized}}
+ B(char (*)[13]) : a(std::move(x ? a : (25, a))) {} // expected-warning 2{{uninitialized}}
};
struct C {
- C() {} // expected-note8{{in this constructor}}
+ C() {} // expected-note9{{in this constructor}}
A a1 = a1; // expected-warning {{uninitialized}}
A a2 = a2.get(); // expected-warning {{uninitialized}}
A a3 = a3.num();
A a11 = std::move(a11); // expected-warning {{uninitialized}}
A a12 = A(std::move(a12)); // expected-warning {{uninitialized}}
A a13 = rref(std::move(a13)); // expected-warning {{uninitialized}}
+ A a14 = std::move(x ? a13 : (22, a14)); // expected-warning {{uninitialized}}
};
- struct D { // expected-note8{{in the implicit default constructor}}
+ struct D { // expected-note9{{in the implicit default constructor}}
A a1 = a1; // expected-warning {{uninitialized}}
A a2 = a2.get(); // expected-warning {{uninitialized}}
A a3 = a3.num();
A a11 = std::move(a11); // expected-warning {{uninitialized}}
A a12 = A(std::move(a12)); // expected-warning {{uninitialized}}
A a13 = rref(std::move(a13)); // expected-warning {{uninitialized}}
+ A a14 = std::move(x ? a13 : (22, a14)); // expected-warning {{uninitialized}}
};
D d;
struct E {
A a11 = std::move(a11);
A a12 = A(std::move(a12));
A a13 = rref(std::move(a13));
+ A a14 = std::move(x ? a13 : (22, a14));
};
}