[clang] [Clang][Sema] Earlier type checking for builtin unary operators (PR #90500)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue May 14 13:01:20 PDT 2024


erichkeane wrote:

> Well this took forever to reduce:
> 
> ```c++
> template<typename T>
> struct A;
> 
> template<typename T>
> bool operator==(const A<T>&, const A<T>&);
> 
> template<typename>
> void f(int *x)
> {
>     [&](auto *y) { return x == y; };
> }
> 
> void g()
> {
>     f<int>(nullptr);
> }
> ```
> 
> We initially build a `CXXOperatorCallExpr` during parsing for the comparison, but `TreeTransform` prematurely rebuilds it as a builtin binary operator when `f` is instantiated.

Yeah, unfortunately that is a limitation of Clang, we still don't correctly implement the instantiation of Lambdas.  We do so 'greedily', in a way that the standard doesn't allow.  We eventually need to delay ALL instantiation until the actual first full instantiation of the lambda.

That said, in this case I'm surprised that we don't skip that diagnostic based on the RHS (in your repro) being dependent.  THAT would probably fix this case at least.

https://github.com/llvm/llvm-project/pull/90500


More information about the cfe-commits mailing list