Skip to content

Commit

Permalink
[Clang] Remove the special-casing for RequiresExprBodyDecl in BuildRe…
Browse files Browse the repository at this point in the history
…solvedCallExpr() 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

(cherry picked from commit 8c15470)
  • Loading branch information
zyn0217 authored and tru committed Oct 11, 2024
1 parent 33a5c88 commit f3f4952
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
3 changes: 1 addition & 2 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6922,8 +6922,7 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
}

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

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -13608,7 +13608,7 @@ bool TreeTransform<Derived>::TransformOverloadExprDecls(OverloadExpr *Old,
}

AllEmptyPacks &= Decls.empty();
};
}

// C++ [temp.res]/8.4.2:
// The program is ill-formed, no diagnostic required, if [...] lookup for
Expand Down
23 changes: 0 additions & 23 deletions clang/test/SemaCXX/PR84020.cpp

This file was deleted.

31 changes: 31 additions & 0 deletions clang/test/SemaTemplate/instantiate-requires-expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,34 @@ constexpr bool e_v = true;
static_assert(e_v<bool>);

} // namespace GH73885

namespace GH84020 {

struct B {
template <typename S> void foo();
void bar();
};

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

template class A<B, double>;

} // namespace GH84020

namespace GH110785 {

struct Foo {
static void f(auto) requires(false) {}
void f(int) {}

static_assert([](auto v) {
return requires { f(v); };
} (0) == false);
};

} // namespace GH110785

0 comments on commit f3f4952

Please sign in to comment.