Issue 136624
Summary Incorrect name qualification in AST / diagnostics for alias CTAD
Labels clang:frontend
Assignees mizvekov
Reporter mizvekov
    Consider this example: https://compiler-explorer.com/z/bGqdsa3qc

```C++
template<typename U> struct A {
  U t;
};

template<typename V> A(V) -> A<V>;

namespace foo {
  template<class Y> using Alias = A<Y>;
}

foo::Alias t = 0;
```

Produces:
```
error: no viable conversion from 'int' to 'foo::A<int>' (aka 'A<int>')
```

Note that the `foo::` qualification is applied to Alias in the source code, which is in that namespace, but
on the AST (and consequently in the diagnostic) it gets applied to `A` , where it cannot be found.

The problem here is many fold:
1) We have an elaborated type including `foo::` over the deduced template specialization (DTST), which names `foo::Alias`.
2) However, when printing a DTST which has already been deduced, we choose to print it as the deduced type instead, probably for diagnostics reasons (although this is wrong for -ast-print, and we don't control this with a policy).
3) For alias CTAD, we don't build a guide which actually contains the alias template specialization `Alias<int>`, instead the guide contains `A<int>`.

I see  a couple of solutions:
* If we fix 3, then this would print as intended: `'foo::Alias<int>' (aka 'A<int>')`
* We could stop doing 2, then this would print as `'foo::Alias' (aka 'A<int>')`.
 The first type does not include much information, as 2) probably intended to avoid, but it is correctly qualified, and then the 'aka' gives the missing information.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to