annotate clang/test/SemaTemplate/explicit-specialization-member.cpp @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s -fcxx-exceptions
anatofuz
parents:
diff changeset
2 template<typename T>
anatofuz
parents:
diff changeset
3 struct X0 {
anatofuz
parents:
diff changeset
4 typedef T* type;
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 void f0(T);
anatofuz
parents:
diff changeset
7 void f1(type);
anatofuz
parents:
diff changeset
8 };
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 template<> void X0<char>::f0(char);
anatofuz
parents:
diff changeset
11 template<> void X0<char>::f1(type);
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 namespace PR6161 {
anatofuz
parents:
diff changeset
14 template<typename _CharT>
anatofuz
parents:
diff changeset
15 class numpunct : public locale::facet // expected-error{{use of undeclared identifier 'locale'}} \
anatofuz
parents:
diff changeset
16 // expected-error{{expected class name}}
anatofuz
parents:
diff changeset
17 {
anatofuz
parents:
diff changeset
18 static locale::id id; // expected-error{{use of undeclared identifier}}
anatofuz
parents:
diff changeset
19 };
anatofuz
parents:
diff changeset
20 numpunct<char>::~numpunct();
anatofuz
parents:
diff changeset
21 }
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 namespace PR12331 {
anatofuz
parents:
diff changeset
24 template<typename T> struct S {
anatofuz
parents:
diff changeset
25 struct U { static const int n = 5; };
anatofuz
parents:
diff changeset
26 enum E { e = U::n }; // expected-note {{implicit instantiation first required here}}
anatofuz
parents:
diff changeset
27 int arr[e];
anatofuz
parents:
diff changeset
28 };
anatofuz
parents:
diff changeset
29 template<> struct S<int>::U { static const int n = sizeof(int); }; // expected-error {{explicit specialization of 'U' after instantiation}}
anatofuz
parents:
diff changeset
30 }
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 namespace PR18246 {
anatofuz
parents:
diff changeset
33 template<typename T>
anatofuz
parents:
diff changeset
34 class Baz {
anatofuz
parents:
diff changeset
35 public:
anatofuz
parents:
diff changeset
36 template<int N> void bar();
anatofuz
parents:
diff changeset
37 };
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 template<typename T>
anatofuz
parents:
diff changeset
40 template<int N>
anatofuz
parents:
diff changeset
41 void Baz<T>::bar() {
anatofuz
parents:
diff changeset
42 }
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 template<typename T>
anatofuz
parents:
diff changeset
45 void Baz<T>::bar<0>() { // expected-error {{cannot specialize a member of an unspecialized template}}
anatofuz
parents:
diff changeset
46 }
anatofuz
parents:
diff changeset
47 }
anatofuz
parents:
diff changeset
48
anatofuz
parents:
diff changeset
49 namespace PR19340 {
anatofuz
parents:
diff changeset
50 template<typename T> struct Helper {
anatofuz
parents:
diff changeset
51 template<int N> static void func(const T *m) {}
anatofuz
parents:
diff changeset
52 };
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 template<typename T> void Helper<T>::func<2>() {} // expected-error {{cannot specialize a member}}
anatofuz
parents:
diff changeset
55 }
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 namespace SpecLoc {
anatofuz
parents:
diff changeset
58 template <typename T> struct A {
anatofuz
parents:
diff changeset
59 static int n; // expected-note {{previous}}
anatofuz
parents:
diff changeset
60 static void f(); // expected-note {{previous}}
anatofuz
parents:
diff changeset
61 };
anatofuz
parents:
diff changeset
62 template<> float A<int>::n; // expected-error {{different type}}
anatofuz
parents:
diff changeset
63 template<> void A<int>::f() throw(); // expected-error {{does not match}}
anatofuz
parents:
diff changeset
64 }
anatofuz
parents:
diff changeset
65
anatofuz
parents:
diff changeset
66 namespace PR41607 {
anatofuz
parents:
diff changeset
67 template<int N> struct Outer {
anatofuz
parents:
diff changeset
68 template<typename...> struct Inner;
anatofuz
parents:
diff changeset
69 template<> struct Inner<> {
anatofuz
parents:
diff changeset
70 static constexpr int f() { return N; }
anatofuz
parents:
diff changeset
71 };
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 template<typename...> static int a;
anatofuz
parents:
diff changeset
74 template<> static constexpr int a<> = N;
anatofuz
parents:
diff changeset
75
anatofuz
parents:
diff changeset
76 template<typename...> static inline int b;
anatofuz
parents:
diff changeset
77 template<> static inline constexpr int b<> = N;
anatofuz
parents:
diff changeset
78
anatofuz
parents:
diff changeset
79 template<typename...> static constexpr int f();
anatofuz
parents:
diff changeset
80 template<> static constexpr int f() {
anatofuz
parents:
diff changeset
81 return N;
anatofuz
parents:
diff changeset
82 }
anatofuz
parents:
diff changeset
83 };
anatofuz
parents:
diff changeset
84 static_assert(Outer<123>::Inner<>::f() == 123, "");
anatofuz
parents:
diff changeset
85 static_assert(Outer<123>::Inner<>::f() != 125, "");
anatofuz
parents:
diff changeset
86
anatofuz
parents:
diff changeset
87 static_assert(Outer<123>::a<> == 123, "");
anatofuz
parents:
diff changeset
88 static_assert(Outer<123>::a<> != 125, "");
anatofuz
parents:
diff changeset
89
anatofuz
parents:
diff changeset
90 static_assert(Outer<123>::b<> == 123, "");
anatofuz
parents:
diff changeset
91 static_assert(Outer<123>::b<> != 125, "");
anatofuz
parents:
diff changeset
92
anatofuz
parents:
diff changeset
93 static_assert(Outer<123>::f<>() == 123, "");
anatofuz
parents:
diff changeset
94 static_assert(Outer<123>::f<>() != 125, "");
anatofuz
parents:
diff changeset
95 }