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:
@@ -479,13 +479,15 @@ public:
|
|||||||
QualType SavedCXXThisTypeOverride;
|
QualType SavedCXXThisTypeOverride;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ContextRAII(Sema &S, DeclContext *ContextToPush)
|
ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
|
||||||
: S(S), SavedContext(S.CurContext),
|
: S(S), SavedContext(S.CurContext),
|
||||||
SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
|
SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
|
||||||
SavedCXXThisTypeOverride(S.CXXThisTypeOverride)
|
SavedCXXThisTypeOverride(S.CXXThisTypeOverride)
|
||||||
{
|
{
|
||||||
assert(ContextToPush && "pushing null context");
|
assert(ContextToPush && "pushing null context");
|
||||||
S.CurContext = ContextToPush;
|
S.CurContext = ContextToPush;
|
||||||
|
if (NewThisContext)
|
||||||
|
S.CXXThisTypeOverride = QualType();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pop() {
|
void pop() {
|
||||||
|
|||||||
@@ -8339,7 +8339,8 @@ TreeTransform<Derived>::TransformLambdaScope(LambdaExpr *E,
|
|||||||
bool Invalid = false;
|
bool Invalid = false;
|
||||||
|
|
||||||
// Introduce the context of the call operator.
|
// Introduce the context of the call operator.
|
||||||
Sema::ContextRAII SavedContext(getSema(), CallOperator);
|
Sema::ContextRAII SavedContext(getSema(), CallOperator,
|
||||||
|
/*NewThisContext*/false);
|
||||||
|
|
||||||
LambdaScopeInfo *const LSI = getSema().getCurLambda();
|
LambdaScopeInfo *const LSI = getSema().getCurLambda();
|
||||||
// Enter the scope of the lambda.
|
// Enter the scope of the lambda.
|
||||||
|
|||||||
@@ -100,3 +100,13 @@ namespace rdar14084171 {
|
|||||||
};
|
};
|
||||||
void f(Sprite& x) { x = x; }
|
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(); };
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user