From aca7068c6227c51913e33e0b963b6f4013309418 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 9 Sep 2019 23:07:22 +0000 Subject: [PATCH] PR43242: Fix crash when typo-correcting to an operator() that should not have been visible. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371468 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 11 +---------- test/SemaCXX/lambda-expressions.cpp | 4 ++++ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 816d37e0b5..98f98be169 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1990,16 +1990,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, R.clear(); } - // In Microsoft mode, if we are performing lookup from within a friend - // function definition declared at class scope then we must set - // DC to the lexical parent to be able to search into the parent - // class. - if (getLangOpts().MSVCCompat && isa(DC) && - cast(DC)->getFriendObjectKind() && - DC->getLexicalParent()->isRecord()) - DC = DC->getLexicalParent(); - else - DC = DC->getParent(); + DC = DC->getLookupParent(); } // We didn't find anything, so try to correct for a typo. diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp index 311def9147..5fff855102 100644 --- a/test/SemaCXX/lambda-expressions.cpp +++ b/test/SemaCXX/lambda-expressions.cpp @@ -630,3 +630,7 @@ void Run(const int& points) { }; } } + +void operator_parens() { + [&](int x){ operator()(); }(0); // expected-error {{undeclared 'operator()'}} +} -- 2.40.0