Skip to content

Commit 8c15470

Browse files
authored
[Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d76 (#111277)
The special-casing for RequiresExprBodyDecl caused a regression, as reported in #110785. The original fix for #84020 has been superseded by fd87d76, which establishes a `DependentScopeDeclRefExpr` instead of a `CXXDependentScopeMemberExpr` for the case in issue. So the spurious diagnostic in #84020 would no longer occur. This also merges the test for #84020 together with that for #110785 into clang/test/SemaTemplate/instantiate-requires-expr.cpp. No release note because I think this merits a backport. Fixes #110785
1 parent b672071 commit 8c15470

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

clang/lib/Sema/SemaExpr.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -6963,8 +6963,7 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
69636963
}
69646964

69656965
if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
6966-
if (!isa<RequiresExprBodyDecl>(CurContext) &&
6967-
Method->isImplicitObjectMemberFunction())
6966+
if (Method->isImplicitObjectMemberFunction())
69686967
return ExprError(Diag(LParenLoc, diag::err_member_call_without_object)
69696968
<< Fn->getSourceRange() << 0);
69706969

clang/lib/Sema/TreeTransform.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13907,7 +13907,7 @@ bool TreeTransform<Derived>::TransformOverloadExprDecls(OverloadExpr *Old,
1390713907
}
1390813908

1390913909
AllEmptyPacks &= Decls.empty();
13910-
};
13910+
}
1391113911

1391213912
// C++ [temp.res]/8.4.2:
1391313913
// The program is ill-formed, no diagnostic required, if [...] lookup for

clang/test/SemaCXX/PR84020.cpp

-23
This file was deleted.

clang/test/SemaTemplate/instantiate-requires-expr.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,34 @@ constexpr bool e_v = true;
237237
static_assert(e_v<bool>);
238238

239239
} // namespace GH73885
240+
241+
namespace GH84020 {
242+
243+
struct B {
244+
template <typename S> void foo();
245+
void bar();
246+
};
247+
248+
template <typename T, typename S> struct A : T {
249+
void foo() {
250+
static_assert(requires { T::template foo<S>(); });
251+
static_assert(requires { T::bar(); });
252+
}
253+
};
254+
255+
template class A<B, double>;
256+
257+
} // namespace GH84020
258+
259+
namespace GH110785 {
260+
261+
struct Foo {
262+
static void f(auto) requires(false) {}
263+
void f(int) {}
264+
265+
static_assert([](auto v) {
266+
return requires { f(v); };
267+
} (0) == false);
268+
};
269+
270+
} // namespace GH110785

0 commit comments

Comments
 (0)