[clang] [clang] Avoid assertion on invalid member template specialization (PR #201506)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 12 01:59:02 PDT 2026


================
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// regression test for https://github.com/llvm/llvm-project/issues/201490
+template<class T> struct A {};
+template<class T> struct B : A<T> {};
+template<> template<class T> class A<int>::B {}; // expected-error{{out-of-line definition of 'B' does not match any declaration in 'A<int>'}}
+
+// A legitimate member class template explicit specialization
+template<class T> struct C { template<class U> struct D; };
+  template<> template<class U> struct C<int>::D {};
----------------
zyn0217 wrote:

I'd suggest you move this small test to an existing file whose name matches what you fix, wrap the test with `namespace GH201490` and remove the unnecessary comments which seem to be added by an AI agent
`// regression test for https://github.com/llvm/llvm-project/issues/201490`
`// A legitimate member class template explicit specialization`

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


More information about the cfe-commits mailing list