PR43242: Fix crash when typo-correcting to an operator() that should not
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 9 Sep 2019 23:07:22 +0000 (23:07 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 9 Sep 2019 23:07:22 +0000 (23:07 +0000)
have been visible.

llvm-svn: 371468

clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/lambda-expressions.cpp

index 816d37e..98f98be 100644 (file)
@@ -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<FunctionDecl>(DC) &&
-        cast<FunctionDecl>(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.
index 311def9..5fff855 100644 (file)
@@ -630,3 +630,7 @@ void Run(const int& points) {
   };
 }
 }
+
+void operator_parens() {
+  [&](int x){ operator()(); }(0); // expected-error {{undeclared 'operator()'}}
+}