r371468 - PR43242: Fix crash when typo-correcting to an operator() that should not

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 9 16:07:23 PDT 2019


Author: rsmith
Date: Mon Sep  9 16:07:22 2019
New Revision: 371468

URL: http://llvm.org/viewvc/llvm-project?rev=371468&view=rev
Log:
PR43242: Fix crash when typo-correcting to an operator() that should not
have been visible.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaCXX/lambda-expressions.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=371468&r1=371467&r2=371468&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Sep  9 16:07:22 2019
@@ -1990,16 +1990,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S,
       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.

Modified: cfe/trunk/test/SemaCXX/lambda-expressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/lambda-expressions.cpp?rev=371468&r1=371467&r2=371468&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/trunk/test/SemaCXX/lambda-expressions.cpp Mon Sep  9 16:07:22 2019
@@ -630,3 +630,7 @@ void Run(const int& points) {
   };
 }
 }
+
+void operator_parens() {
+  [&](int x){ operator()(); }(0); // expected-error {{undeclared 'operator()'}}
+}




More information about the cfe-commits mailing list