https://github.com/Backl1ght updated https://github.com/llvm/llvm-project/pull/95651
>From 49f0d1aff888b2a96ed3a19d8d2e30d367caf14f Mon Sep 17 00:00:00 2001 From: Backl1ght <backlight....@gmail.com> Date: Sat, 15 Jun 2024 16:56:00 +0800 Subject: [PATCH] fix --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Sema/SemaTemplateInstantiate.cpp | 2 +- .../expr.prim.req/compound-requirement.cpp | 36 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 36efeb8c70cca..3717e573419e7 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -858,6 +858,7 @@ Bug Fixes to C++ Support - Fixed several bugs in capturing variables within unevaluated contexts. (#GH63845), (#GH67260), (#GH69307), (#GH88081), (#GH89496), (#GH90669) and (#GH91633). - Fixed handling of brace ellison when building deduction guides. (#GH64625), (#GH83368). +- Fixed a bug in access checking inside return-type-requirement of compound requirements. (#GH93788). Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 863cc53c55afa..1fe1fe9d4f833 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2735,7 +2735,7 @@ TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) { if (TPLInst.isInvalid()) return nullptr; TemplateParameterList *TPL = TransformTemplateParameterList(OrigTPL); - if (!TPL) + if (!TPL || Trap.hasErrorOccurred()) TransRetReq.emplace(createSubstDiag(SemaRef, Info, [&] (llvm::raw_ostream& OS) { RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint() diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp index b7366207882f9..dc0e84280e056 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp @@ -189,3 +189,39 @@ namespace std_example { template<C5 T> struct C5_check {}; // expected-note{{because 'short' does not satisfy 'C5'}} using c5 = C5_check<short>; // expected-error{{constraints not satisfied for class template 'C5_check' [with T = short]}} } + +namespace access_checks { +namespace in_return_type_requirement { + +// https://github.com/llvm/llvm-project/issues/93788 +template <typename From, typename To> +concept is_assignable = requires(From from, To to) { + from = to; +}; + +template <typename T> +class trait { + public: + using public_type = int; + private: + using private_type = int; +}; + +template <typename T> +concept has_field = requires(T t) { + { t.field } -> is_assignable<typename trait<T>::private_type>; // expected-note {{'private_type' is a private member}} +}; +template <typename T> +concept has_field2 = requires(T t) { + { t.field } -> is_assignable<typename trait<T>::public_type>; +}; + +struct A { + int field; +}; +static_assert(has_field<A>); // expected-error {{static assertion failed}} \ + // expected-note {{because 'A' does not satisfy 'has_field'}} +static_assert(has_field2<A>); + +} // namespace access_checks +} // namespace in_return_type_requirement _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits