[clang] [Clang] Diagnose invalid function types in dependent contexts (PR #138731)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue May 6 11:14:29 PDT 2025


================
@@ -6594,6 +6603,16 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
             *this, dyn_cast<UnresolvedMemberExpr>(Fn->IgnoreParens()),
             Fn->getBeginLoc());
 
+        if (!Fn->getType()->isDependentType()) {
+          // If the type of the function itself is not dependent
+          // check that it is a reasonable as a function, as type deduction
+          // later assume the CallExpr has a sensible TYPE.
+          if (!MayBeFunctionType(Context, Fn->getType()))
----------------
erichkeane wrote:

I might suggest putting these in teh same 'if' to make it more obvious what is happening (or perhaps have `MayBeFunctionType` return `true` for a dependent type?

https://github.com/llvm/llvm-project/pull/138731


More information about the cfe-commits mailing list