PR18560: When switching to a new context, don't just save and restore an

override for the type of 'this', also clear it out (unless we're entering the
context of a lambda-expression, where it should be inherited).

llvm-svn: 199962
This commit is contained in:
Richard Smith 2014-01-24 01:54:52 +00:00
parent 3e92a2b013
commit 7ff2bcb814
3 changed files with 15 additions and 2 deletions

View File

@ -479,13 +479,15 @@ public:
QualType SavedCXXThisTypeOverride;
public:
ContextRAII(Sema &S, DeclContext *ContextToPush)
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
: S(S), SavedContext(S.CurContext),
SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
SavedCXXThisTypeOverride(S.CXXThisTypeOverride)
{
assert(ContextToPush && "pushing null context");
S.CurContext = ContextToPush;
if (NewThisContext)
S.CXXThisTypeOverride = QualType();
}
void pop() {

View File

@ -8339,7 +8339,8 @@ TreeTransform<Derived>::TransformLambdaScope(LambdaExpr *E,
bool Invalid = false;
// Introduce the context of the call operator.
Sema::ContextRAII SavedContext(getSema(), CallOperator);
Sema::ContextRAII SavedContext(getSema(), CallOperator,
/*NewThisContext*/false);
LambdaScopeInfo *const LSI = getSema().getCurLambda();
// Enter the scope of the lambda.

View File

@ -100,3 +100,13 @@ namespace rdar14084171 {
};
void f(Sprite& x) { x = x; }
}
namespace PR18560 {
struct X { int m; };
template<typename T = X,
typename U = decltype(T::m)>
int f();
struct Y { int b = f(); };
}