aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-03-26 03:41:40 +0000
committerRichard Trieu <rtrieu@google.com>2013-03-26 03:41:40 +0000
commit8af742a499bf13f0a3d53b03aa44ae748fadd61e (patch)
treec76b4de5a1758c1a89ca8c6277dfe7e621a6709f
parent9cc935b6993460956d0d46ee268e9858743d5129 (diff)
Handle CXXOperatorCallExpr when checking self referrnce during initialization of
class types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177987 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDecl.cpp8
-rw-r--r--test/SemaCXX/uninitialized.cpp15
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index cb05bb0099..9261df559e 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -7097,6 +7097,14 @@ namespace {
Visit(Base);
}
+ void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
+ if (E->getNumArgs() > 0)
+ if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E->getArg(0)))
+ HandleDeclRefExpr(DRE);
+
+ Inherited::VisitCXXOperatorCallExpr(E);
+ }
+
void VisitUnaryOperator(UnaryOperator *E) {
// For POD record types, addresses of its own members are well-defined.
if (E->getOpcode() == UO_AddrOf && isRecordType &&
diff --git a/test/SemaCXX/uninitialized.cpp b/test/SemaCXX/uninitialized.cpp
index 3a41114e87..2aa56623f6 100644
--- a/test/SemaCXX/uninitialized.cpp
+++ b/test/SemaCXX/uninitialized.cpp
@@ -496,3 +496,18 @@ namespace references {
int &b;
};
}
+
+namespace operators {
+ struct A {
+ A(bool);
+ bool operator==(A);
+ };
+
+ A makeA();
+
+ A a1 = a1 = makeA(); // expected-warning{{variable 'a1' is uninitialized when used within its own initialization}}
+ A a2 = a2 == a1; // expected-warning{{variable 'a2' is uninitialized when used within its own initialization}}
+ A a3 = a2 == a3; // expected-warning{{variable 'a3' is uninitialized when used within its own initialization}}
+
+ int x = x = 5;
+}