diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-20 02:08:33 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-20 02:08:33 +0000 |
commit | f6702a3927147655206ae729a84339c4fda4c651 (patch) | |
tree | 8ce5a4586e757043987e0dcf0f523cea068f4812 /lib/Sema/SemaDeclCXX.cpp | |
parent | 9490ab433deef70105d817616928d700f87642d9 (diff) |
Unlike in C++03, a constant-expression is not an unevaluated operand in C++11.
Split out a new ExpressionEvaluationContext flag for this case, and don't treat
it as unevaluated in C++11. This fixes some crash-on-invalids where we would
allow references to class members in potentially-evaluated constant expressions
in static member functions, and also fixes half of PR10177.
The fix to PR10177 exposed a case where template instantiation failed to provide
a source location for a diagnostic, so TreeTransform has been tweaked to supply
source locations when transforming a type. The source location is still not very
good, but MarkDeclarationsReferencedInType would need to operate on a TypeLoc to
improve it further.
Also fix MarkDeclarationReferenced in C++98 mode to trigger instantiation for
static data members of class templates which are used in constant expressions.
This fixes a link-time problem, but we still incorrectly treat the member as
non-constant. The rest of the fix for that issue is blocked on PCH support for
early-instantiated static data members, which will be added in a subsequent
patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146955 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 2176afa92d..f8c02ba741 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -10515,7 +10515,8 @@ void Sema::MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, // not have a vtable. if (!Class->isDynamicClass() || Class->isDependentContext() || CurContext->isDependentContext() || - ExprEvalContexts.back().Context == Unevaluated) + ExprEvalContexts.back().Context == Unevaluated || + ExprEvalContexts.back().Context == ConstantEvaluated) return; // Try to insert this class into the map. |