[clang] [Clang][Sema] Handle invalid variable template specialization whose type depends on itself (PR #134522)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 8 06:56:13 PDT 2025
================
@@ -47,3 +47,21 @@ namespace InvalidInsertPos {
template<> int v<int, 0>;
int k = v<int, 500>;
}
+
+namespace GH51347 {
+ template <typename T>
+ auto p = p<T>; // expected-error {{the type of variable template specialization 'p<int>'}}
----------------
erichkeane wrote:
It should be the same/similar as when we recognize the `auto x= x +1 ` or `int x = x + 1;` (one is an error, the other is a warning).
This is probably fine if this isn't a primary template, right?
Generally, Clang templates try to diagnose things as absolute early as possible so we get ONE error instead of one-per-instantiation.
That said, it is perhaps worth spending some time to see if there is a reason we can't, or, by language rule, shouldn't diagnose this on `auto p = p <T>;`
https://github.com/llvm/llvm-project/pull/134522
More information about the cfe-commits
mailing list