diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-20 21:42:12 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-20 21:42:12 +0000 |
commit | 0e9e9814a7f8313c0c02b6afea71f0e4c411873e (patch) | |
tree | 2545862745d5ca6fb5b0a4db116ae1af1d1861b5 /lib/Sema/SemaDecl.cpp | |
parent | ef47d27b9c76ed2f20e6c342e66b5450ef7e96ee (diff) |
Add -Wc++98-compat diagnostics for jumps which bypass initialization of non-POD
but trivially constructible and destructible variables in C++11 mode. Also
incidentally improve the precision of the wording for jump diagnostics in C++98
mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142619 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index f4c5237ff2..b06b884450 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -6358,7 +6358,7 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl, // Check for jumps past the implicit initializer. C++0x // clarifies that this applies to a "variable with automatic // storage duration", not a "local variable". - // C++0x [stmt.dcl]p3 + // C++11 [stmt.dcl]p3 // A program that jumps from a point where a variable with automatic // storage duration is not in scope to a point where it is in scope is // ill-formed unless the variable has scalar type, class type with a @@ -6369,10 +6369,10 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl, if (const RecordType *Record = Context.getBaseElementType(Type)->getAs<RecordType>()) { CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl()); - if ((!getLangOptions().CPlusPlus0x && !CXXRecord->isPOD()) || - (getLangOptions().CPlusPlus0x && - (!CXXRecord->hasTrivialDefaultConstructor() || - !CXXRecord->hasTrivialDestructor()))) + // Mark the function for further checking even if the looser rules of + // C++11 do not require such checks, so that we can diagnose + // incompatibilities with C++98. + if (!CXXRecord->isPOD()) getCurFunction()->setHasBranchProtectedScope(); } } |