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 (llvm#111277)

The special-casing for RequiresExprBodyDecl caused a regression, as
reported in llvm#110785.

The original fix for llvm#84020 has been superseded by fd87d76, which
establishes a `DependentScopeDeclRefExpr` instead of a
`CXXDependentScopeMemberExpr` for the case in issue. So the spurious
diagnostic in llvm#84020 would no longer occur.

This also merges the test for llvm#84020 together with that for llvm#110785 into
clang/test/SemaTemplate/instantiate-requires-expr.cpp.

No release note because I think this merits a backport.

Fixes llvm#110785
  • Loading branch information
zyn0217 authored Oct 7, 2024
1 parent b672071 commit 8c15470
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 @@ -6963,8 +6963,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 @@ -13907,7 +13907,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 8c15470

Please sign in to comment.