void VisitObjCMessageExpr(ObjCMessageExpr *E) { return; }
+ void VisitCXXConstructExpr(CXXConstructExpr *E) {
+ if (E->getConstructor()->isCopyConstructor()) {
+ if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E->getArg(0))) {
+ HandleDeclRefExpr(DRE);
+ }
+ }
+ Inherited::VisitCXXConstructExpr(E);
+ }
+
void HandleDeclRefExpr(DeclRefExpr *DRE) {
Decl* ReferenceDecl = DRE->getDecl();
if (OrigDecl != ReferenceDecl) return;
}
void VisitCXXConstructExpr(CXXConstructExpr *E) {
- if (E->getConstructor()->isCopyConstructor())
- if (ImplicitCastExpr* ICE = dyn_cast<ImplicitCastExpr>(E->getArg(0)))
- if (ICE->getCastKind() == CK_NoOp)
- if (MemberExpr *ME = dyn_cast<MemberExpr>(ICE->getSubExpr()))
- HandleMemberExpr(ME, false /*CheckReferenceOnly*/);
-
+ if (E->getConstructor()->isCopyConstructor()) {
+ Expr *ArgExpr = E->getArg(0);
+ if (ImplicitCastExpr* ICE = dyn_cast<ImplicitCastExpr>(ArgExpr)) {
+ if (ICE->getCastKind() == CK_NoOp) {
+ ArgExpr = ICE->getSubExpr();
+ }
+ }
+
+ if (MemberExpr *ME = dyn_cast<MemberExpr>(ArgExpr)) {
+ HandleMemberExpr(ME, false /*CheckReferenceOnly*/);
+ }
+ }
Inherited::VisitCXXConstructExpr(E);
}
A *a26 = new A(a26->get()); // expected-warning {{variable 'a26' is uninitialized when used within its own initialization}}
A *a27 = new A(a27->get2()); // expected-warning {{variable 'a27' is uninitialized when used within its own initialization}}
A *a28 = new A(a28->num); // expected-warning {{variable 'a28' is uninitialized when used within its own initialization}}
+
+ const A a29(a29); // expected-warning {{variable 'a29' is uninitialized when used within its own initialization}}
+ const A a30 = a30; // expected-warning {{variable 'a30' is uninitialized when used within its own initialization}}
}
bool x;
A *a27 = new A(a27->get2()); // expected-warning {{variable 'a27' is uninitialized when used within its own initialization}}
A *a28 = new A(a28->num); // expected-warning {{variable 'a28' is uninitialized when used within its own initialization}}
+const A a29(a29); // expected-warning {{variable 'a29' is uninitialized when used within its own initialization}}
+const A a30 = a30; // expected-warning {{variable 'a30' is uninitialized when used within its own initialization}}
+
struct B {
// POD struct.
int x;
B b17 = { b17.x = 5, b17.y = 0 };
B b18 = { b18.x + 1, b18.y }; // expected-warning 2{{variable 'b18' is uninitialized when used within its own initialization}}
+
+ const B b19 = b19; // expected-warning {{variable 'b19' is uninitialized when used within its own initialization}}
+ const B b20(b20); // expected-warning {{variable 'b20' is uninitialized when used within its own initialization}}
+
}
B b1;
B b17 = { b17.x = 5, b17.y = 0 };
B b18 = { b18.x + 1, b18.y }; // expected-warning 2{{variable 'b18' is uninitialized when used within its own initialization}}
+const B b19 = b19; // expected-warning {{variable 'b19' is uninitialized when used within its own initialization}}
+const B b20(b20); // expected-warning {{variable 'b20' is uninitialized when used within its own initialization}}
// Also test similar constructs in a field's initializer.
struct S {
G(char (*)[7]) : f3(f3->*f_ptr) {} // expected-warning {{field 'f3' is uninitialized when used here}}
G(char (*)[8]) : f3(new F(f3->*ptr)) {} // expected-warning {{field 'f3' is uninitialized when used here}}
};
+
+ struct H {
+ H() : a(a) {} // expected-warning {{field 'a' is uninitialized when used here}}
+ const A a;
+ };
}
namespace statics {
B(char (*)[9]) : a(normal(a)) {} // expected-warning {{uninitialized}}
};
struct C {
- C() {} // expected-note4{{in this constructor}}
+ C() {} // expected-note5{{in this constructor}}
A a1 = a1; // expected-warning {{uninitialized}}
A a2 = a2.get(); // expected-warning {{uninitialized}}
A a3 = a3.num();
A a7 = const_ref(a7);
A a8 = pointer(&a8);
A a9 = normal(a9); // expected-warning {{uninitialized}}
+ const A a10 = a10; // expected-warning {{uninitialized}}
};
- struct D { // expected-note4{{in the implicit default constructor}}
+ struct D { // expected-note5{{in the implicit default constructor}}
A a1 = a1; // expected-warning {{uninitialized}}
A a2 = a2.get(); // expected-warning {{uninitialized}}
A a3 = a3.num();
A a7 = const_ref(a7);
A a8 = pointer(&a8);
A a9 = normal(a9); // expected-warning {{uninitialized}}
+ const A a10 = a10; // expected-warning {{uninitialized}}
};
D d;
struct E {
A a7 = const_ref(a7);
A a8 = pointer(&a8);
A a9 = normal(a9);
+ const A a10 = a10;
};
}