[clang] [Clang][Sema] Fix issue on requires expression with templated base class member function (PR #85198)

Qizhi Hu via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 11 07:02:28 PDT 2024


================
@@ -7735,7 +7735,8 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
   }
 
   if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
-    if (Method->isImplicitObjectMemberFunction())
+    if (!isa<RequiresExprBodyDecl>(CurContext) &&
----------------
jcsxky wrote:

In require body, name resolving just lookup function name and don't check function parameter without function call(I think).
```cpp
struct B {
    template <typename S>
    void foo(int);

    void bar();
};

template <typename T, typename S>
struct A : T {
    auto foo() {
        static_assert(requires { T::template foo<S>(); });
        static_assert(requires { T::bar(); });
    }
};

int main() {
    A<B, double> a;
    //a.foo(0);
}
```
After add a parameter to `foo`, this code also compiles correctly without calling.

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


More information about the cfe-commits mailing list