diff options
| author | Richard Trieu <rtrieu@google.com> | 2012-08-06 21:09:23 +0000 |
|---|---|---|
| committer | Richard Trieu <rtrieu@google.com> | 2012-08-06 21:09:23 +0000 |
| commit | 43803f09519301dbc8a37b48d40bb01f8ee7bad3 (patch) | |
| tree | 2ba6ef48607999ad20da16b75eb42854a6858bd3 /clang/lib | |
| parent | 22738d00a30670d5227b47fe2b34d044cebd481c (diff) | |
| download | bcm5719-llvm-43803f09519301dbc8a37b48d40bb01f8ee7bad3.tar.gz bcm5719-llvm-43803f09519301dbc8a37b48d40bb01f8ee7bad3.zip | |
For global record types, the self reference checker was called twice, resulting
in duplicate -Wuninitialized warnings. Change so that only the check in
TryConstructorInitialization() will be used and a single warning be emitted.
llvm-svn: 161345
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c1086fbe142..a512c0364c7 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6310,7 +6310,10 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, // Check for self-references within variable initializers. // Variables declared within a function/method body are handled // by a dataflow analysis. - if (!VDecl->hasLocalStorage() && !VDecl->isStaticLocal()) + // Record types initialized by initializer list are handled here. + // Initialization by constructors are handled in TryConstructorInitialization. + if (!VDecl->hasLocalStorage() && !VDecl->isStaticLocal() && + (isa<InitListExpr>(Init) || !VDecl->getType()->isRecordType())) CheckSelfReference(RealDecl, Init); ParenListExpr *CXXDirectInit = dyn_cast<ParenListExpr>(Init); |

