[InstCombine] Preserve NSW flags for `lshr (mul nuw X, C1), C2 -> mul nuw nsw X,...
[llvm-project.git] / clang / test / SemaTemplate / find-unexpanded-packs.cpp
blobae989c68b50e22640ddd8d283ff944cb8c1211ab
1 // RUN: %clang_cc1 -verify %s -std=c++17 -Wno-unused
3 template<typename ...Ts> void PackInsideTypedefDeclaration() {
4 ([] {
5 typedef Ts Type;
6 (void)Type();
7 }(), ...);
9 template void PackInsideTypedefDeclaration<>();
10 template void PackInsideTypedefDeclaration<int>();
11 template void PackInsideTypedefDeclaration<int, float>();
13 template<typename ...Ts> void PackInsideTypedefDeclarationInvalid() {
14 [] { // expected-error {{contains unexpanded parameter pack 'Ts'}}
15 typedef Ts Type;
16 (void)Type();
19 ([] {
20 typedef Ts Type;
21 // A reference to a typedef containing an unexpanded pack does not
22 // itself contain an unexpanded pack.
23 f(Type()...); // expected-error {{does not contain any unexpanded}}
24 }, ...);
28 template<typename ...Ts> void PackInsideAliasDeclaration() {
29 ([] {
30 using Type = Ts;
31 (void)Type();
32 }(), ...);
34 template void PackInsideAliasDeclaration<>();
35 template void PackInsideAliasDeclaration<int>();
36 template void PackInsideAliasDeclaration<int, float>();
38 template<typename ...Ts> void PackInsideAliasDeclarationInvalid() {
39 [] { // expected-error {{contains unexpanded parameter pack 'Ts'}}
40 using Type = Ts;
41 (void)Type();
43 ([] {
44 using Type = Ts;
45 // A reference to an alias containing an unexpanded pack does not
46 // itself contain an unexpanded pack.
47 f(Type()...); // expected-error {{does not contain any unexpanded}}
48 }, ...);
52 template<typename ...Ts> void PackInsideUsingDeclaration() {
53 ([] {
54 struct A {
55 using Type = Ts;
57 struct B : A {
58 using typename A::Type;
60 (void)typename B::Type();
61 }(), ...);
63 template void PackInsideUsingDeclaration<>();
64 template void PackInsideUsingDeclaration<int>();
65 template void PackInsideUsingDeclaration<int, float>();
67 template<typename ...Ts> void PackInsideUsingDeclarationInvalid() {
68 ([] {
69 struct A {
70 using Type = Ts;
72 struct B : A {
73 using typename A::Type...; // expected-error {{does not contain any unexpanded}}
75 }(), ...);
79 template<typename ...Ts> void PackInsideVarDeclaration() {
80 ([] {
81 Ts ts;
82 (void)ts;
83 }, ...);
85 template void PackInsideVarDeclaration<>();
86 template void PackInsideVarDeclaration<int>();
87 template void PackInsideVarDeclaration<int, float>();
89 template<typename ...Ts> void PackInsideVarDeclarationInvalid() {
90 [] { // expected-error {{contains unexpanded parameter pack 'Ts'}}
91 Ts ts;
92 (void)ts;
97 template<typename ...Ts> void PackInsideFunctionDeclaration() {
98 ([] {
99 Ts ts(Ts);
100 ts({});
101 }, ...);
103 template void PackInsideFunctionDeclaration<>();
104 template void PackInsideFunctionDeclaration<int>();
105 template void PackInsideFunctionDeclaration<int, float>();
107 template<typename ...Ts> void PackInsideFunctionDeclarationInvalid() {
108 [] { // expected-error {{contains unexpanded parameter pack 'Ts'}}
109 Ts ts(Ts);
110 ts({});
115 template<typename ...Ts> void PackInsideLocalClass() {
116 ([] {
117 class Local {
118 Ts ts;
120 Local l;
121 }, ...);
123 template void PackInsideLocalClass<>();
124 template void PackInsideLocalClass<int>();
125 template void PackInsideLocalClass<int, float>();
127 template<typename ...Ts> void PackInsideLocalClassInvalid() {
128 [] { // expected-error {{contains unexpanded parameter pack 'Ts'}}
129 class Local {
130 Ts ts;
132 Local l;
136 template<typename T> using Int = int;
137 struct AClass {};
138 template<typename T> using Class = AClass;
139 template<typename ...Ts> void HiddenPack() {
140 (Int<Ts>(), ...);
141 (Int<Ts>{}, ...);
142 (Class<Ts>(), ...);
143 (Class<Ts>{}, ...);
145 ([] {
146 Int<Ts>();
147 }, ...);
148 ([] {
149 Int<Ts>{};
150 }, ...);
151 ([] {
152 Class<Ts>();
153 }, ...);
154 ([] {
155 Class<Ts>{};
156 }, ...);
158 template void HiddenPack<>();
159 template void HiddenPack<int>();
160 template void HiddenPack<int, float>();
162 template<typename ...Ts> void HiddenPackInvalid() {
163 Int<Ts>(); // expected-error {{unexpanded}}
164 Int<Ts>{}; // expected-error {{unexpanded}}
165 Class<Ts>(); // expected-error {{unexpanded}}
166 Class<Ts>{}; // expected-error {{unexpanded}}