xref: /llvm-project/clang/test/SemaTemplate/gh61159.cpp (revision dcb8911316bec81f4f52b40cf0de789f1839730b)
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
2 // expected-no-diagnostics
3 
4 namespace GH61159 {
5 template <typename T> struct X {
6   struct I;
7 };
8 
9 template <> struct X<int>::I {
fGH61159::X::I10   template <int ct> constexpr int f() { return ct; };
11 
12   int data = 3;
13 };
14 
15 template <typename T> struct X<T>::I {
fGH61159::X::I16   template <T ct> constexpr T f() { return ct + 1; };
17   T data = 7;
18 };
19 
20 static_assert(X<int>::I{}.f<17>() == 17);
21 static_assert(X<int>::I{}.data == 3);
22 static_assert(X<short>::I{}.data == 7);
23 static_assert(X<short>::I{}.f<18>() == 19);
24 
25 template <typename T> struct Y {
26   struct I;
27 };
28 
29 template <> struct Y<int> {
30   struct I {
fGH61159::Y::I31     template <int ct> constexpr int f() { return ct; };
32     int data = 3;
33   };
34 };
35 
36 static_assert(Y<int>::I{}.f<17>() == 17);
37 static_assert(Y<int>::I{}.data == 3);
38 
39 } // namespace GH61159
40