[PATCH] D140547: Perform access checking to private members in simple requirement.

Utkarsh Saxena via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 4 07:24:56 PST 2023


usaxena95 marked an inline comment as done.
usaxena95 added inline comments.


================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1367
+      if (E->getBody()->isDependentContext()) {
+        Sema::SFINAETrap Trap(SemaRef);
+        // We recreate the RequiresExpr body, but not by instantiating it.
----------------
ilya-biryukov wrote:
> Other uses of `PerformDependentDiagnostics` do not add an explicit `SFINAETrap` AFAICS.
> Why is `RequiresExpr` special? Because it should "eat" the errors and only return a value?
Yes. Precisely. 


================
Comment at: clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp:157
+static_assert(A<0>::faz());
+}
----------------
ilya-biryukov wrote:
> Could you add a check that in the following case we mention access check in the note to the `no matching function to call` error?
> 
> ```
> template <class T> struct Use;
> 
> class X { int a; friend struct Use<short>; };
> 
> template <class T> struct Use {
>   static void foo() requires (requires (X x) { x.a; }) {
>   }
> };
> 
> void test() {
>     Use<int>::foo();
> }
> ```
Added. This does not produce any diagnostics. Investigating!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140547/new/

https://reviews.llvm.org/D140547



More information about the cfe-commits mailing list