| 1 |
// PR c++/89833 |
| 2 |
// Test to verify that the same specializations on non-type template |
| 3 |
// parameters of class types are in fact treated as the same. |
| 4 |
// { dg-do compile { target c++20 } } |
| 5 |
|
| 6 |
struct A1 { char c[5]; }; |
| 7 |
|
| 8 |
template <A1> struct B { }; |
| 9 |
|
| 10 |
// All of the following name the same type. |
| 11 |
typedef B<A1{ }> A______; |
| 12 |
typedef B<A1{ { 0 } }> A_Z____; |
| 13 |
typedef B<A1{ { 0, 0 } }> A_ZZ___; |
| 14 |
typedef B<A1{ { 0, 0, 0 } }> A_ZZZ__; |
| 15 |
typedef B<A1{ { 0, 0, 0, 0 } }> A_ZZZZ_; |
| 16 |
typedef B<A1{ { 0, 0, 0, 0, 0 } }> A_ZZZZZ; |
| 17 |
|
| 18 |
// Verify the types are indeed the same by redeclaring the same identifier |
| 19 |
// of each of them. |
| 20 |
extern A______ same_type_B_A1; |
| 21 |
extern A_Z____ same_type_B_A1; |
| 22 |
extern A_ZZ___ same_type_B_A1; |
| 23 |
extern A_ZZZ__ same_type_B_A1; |
| 24 |
extern A_ZZZZ_ same_type_B_A1; |
| 25 |
extern A_ZZZZZ same_type_B_A1; |
| 26 |
|
| 27 |
|
| 28 |
// All of the following use a string to initialize the array but |
| 29 |
// also name the same type as the above. |
| 30 |
typedef B<A1{ "" }> S_z____; |
| 31 |
typedef B<A1{ "\0" }> S_Zz___; |
| 32 |
typedef B<A1{ "\0\0" }> S_ZZz__; |
| 33 |
typedef B<A1{ "\0\0\0" }> S_ZZZz_; |
| 34 |
typedef B<A1{ "\0\0\0\0" }> S_ZZZZz; |
| 35 |
|
| 36 |
// Verify the types are indeed the same by redeclaring the same identifier |
| 37 |
// of each of them. |
| 38 |
extern S_z____ same_type_B_A1; |
| 39 |
extern S_Zz___ same_type_B_A1; |
| 40 |
extern S_Zz___ same_type_B_A1; |
| 41 |
extern S_ZZz__ same_type_B_A1; |
| 42 |
extern S_ZZZz_ same_type_B_A1; |
| 43 |
extern S_ZZZZz same_type_B_A1; |
| 44 |
|
| 45 |
|
| 46 |
// All of the following also name the same type (distinct from |
| 47 |
// the above). |
| 48 |
typedef B<A1{ { 'A' } }> A_A____; |
| 49 |
typedef B<A1{ { 'A', 0 } }> A_AZ___; |
| 50 |
typedef B<A1{ { 'A', 0, 0 } }> A_AZZ__; |
| 51 |
typedef B<A1{ { 'A', 0, 0, 0 } }> A_AZZZ_; |
| 52 |
typedef B<A1{ { 'A', 0, 0, 0, 0 } }> A_AZZZZ; |
| 53 |
|
| 54 |
extern A_A____ same_type_B_A1_A; |
| 55 |
extern A_AZ___ same_type_B_A1_A; |
| 56 |
extern A_AZZ__ same_type_B_A1_A; |
| 57 |
extern A_AZZZ_ same_type_B_A1_A; |
| 58 |
extern A_AZZZZ same_type_B_A1_A; |
| 59 |
|
| 60 |
|
| 61 |
struct A3 { char a[5], b[5], c[5]; }; |
| 62 |
template <A3> struct B3 { }; |
| 63 |
|
| 64 |
// These all name the same type. |
| 65 |
typedef B3<A3{ }> B3_A3________________; |
| 66 |
typedef B3<A3{ { } }> B3_A3________________; |
| 67 |
typedef B3<A3{ { }, { } }> B3_A3________________; |
| 68 |
typedef B3<A3{ { }, { }, { } }> B3_A3________________; |
| 69 |
typedef B3<A3{ { 0 }, { }, { } }> B3_A3________________; |
| 70 |
typedef B3<A3{ { 0 }, { 0 }, { } }> B3_A3________________; |
| 71 |
typedef B3<A3{ { 0 }, { 0 }, { 0 } }> B3_A3________________; |
| 72 |
typedef B3<A3{ { 0, 0 }, { 0 }, { 0 } }> B3_A3________________; |
| 73 |
typedef B3<A3{ { 0, 0 }, { 0, 0 }, { 0 } }> B3_A3________________; |
| 74 |
typedef B3<A3{ { 0, 0 }, { 0, 0 }, { 0, 0 } }> B3_A3________________; |
| 75 |
|
| 76 |
// These all name the same type. |
| 77 |
typedef B3<A3{ "AB", { }, "IJKL" }> B3_A3_AB________IJKL_; |
| 78 |
typedef B3<A3{ "AB", { 0 }, "IJKL" }> B3_A3_AB________IJKL_; |
| 79 |
typedef B3<A3{ "AB", { 0, 0 }, "IJKL" }> B3_A3_AB________IJKL_; |
| 80 |
typedef B3<A3{ "AB", { 0, 0, 0 }, "IJKL" }> B3_A3_AB________IJKL_; |
| 81 |
typedef B3<A3{ "AB", { 0, 0, 0, 0 }, "IJKL" }> B3_A3_AB________IJKL_; |
| 82 |
typedef B3<A3{ "AB", "", "IJKL" }> B3_A3_AB________IJKL_; |
| 83 |
typedef B3<A3{ "AB", "\0", "IJKL" }> B3_A3_AB________IJKL_; |
| 84 |
typedef B3<A3{ "AB", "\0\0", "IJKL" }> B3_A3_AB________IJKL_; |
| 85 |
typedef B3<A3{ "AB", "\0\0\0", "IJKL" }> B3_A3_AB________IJKL_; |
| 86 |
typedef B3<A3{ "AB", "\0\0\0\0", "IJKL" }> B3_A3_AB________IJKL_; |
| 87 |
typedef B3<A3{ "AB\0", "\0\0\0\0", "IJKL" }> B3_A3_AB________IJKL_; |
| 88 |
typedef B3<A3{ "AB\0\0", "\0\0\0\0", "IJKL" }> B3_A3_AB________IJKL_; |
| 89 |
|
| 90 |
// Types with the same name must be the same (and so redefinitions |
| 91 |
// must be accepted). Likewise, overloads on distinct types must |
| 92 |
// be accepted. |
| 93 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0} }> B3_A3________________; |
| 94 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0,0}, {0} }> B3_A3________________; |
| 95 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0,0}, {} }> B3_A3________________; |
| 96 |
typedef B3<A3{ {0,0,0,0,0}, {0}, {} }> B3_A3________________; |
| 97 |
typedef B3<A3{ {0,0,0,0,0}, {}, {} }> B3_A3________________; |
| 98 |
typedef B3<A3{ {0}, {0}, {0} }> B3_A3________________; |
| 99 |
typedef B3<A3{ {0}, {0}, {} }> B3_A3________________; |
| 100 |
typedef B3<A3{ {0}, {}, {0} }> B3_A3________________; |
| 101 |
typedef B3<A3{ {}, {}, {} }> B3_A3________________; |
| 102 |
typedef B3<A3{ {}, {} }> B3_A3________________; |
| 103 |
typedef B3<A3{ {} }> B3_A3________________; |
| 104 |
typedef B3<A3{ }> B3_A3________________; |
| 105 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,1} }> B3_A3_______________1; |
| 106 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0}, {0,0,0,0,1} }> B3_A3_______________1; |
| 107 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0}, {0,0,0,0,1} }> B3_A3_______________1; |
| 108 |
typedef B3<A3{ {0,0,0,0,0}, {0,0}, {0,0,0,0,1} }> B3_A3_______________1; |
| 109 |
typedef B3<A3{ {0,0,0,0,0}, {0}, {0,0,0,0,1} }> B3_A3_______________1; |
| 110 |
typedef B3<A3{ {0,0,0,0,0}, {}, {0,0,0,0,1} }> B3_A3_______________1; |
| 111 |
typedef B3<A3{ {0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,1} }> B3_A3_______________1; |
| 112 |
typedef B3<A3{ {0,0,0}, {0,0,0,0}, {0,0,0,0,1} }> B3_A3_______________1; |
| 113 |
typedef B3<A3{ {0,0}, {0,0,0}, {0,0,0,0,1} }> B3_A3_______________1; |
| 114 |
typedef B3<A3{ {0}, {0,0,}, {0,0,0,0,1} }> B3_A3_______________1; |
| 115 |
typedef B3<A3{ {}, {0}, {0,0,0,0,1} }> B3_A3_______________1; |
| 116 |
typedef B3<A3{ {}, {}, {0,0,0,0,1} }> B3_A3_______________1; |
| 117 |
typedef B3<A3{ {0,0,0}, {0,0}, {0,0,0,1,0} }> B3_A3______________1_; |
| 118 |
typedef B3<A3{ {0,0,0}, {0,0}, {0,0,0,1} }> B3_A3______________1_; |
| 119 |
typedef B3<A3{ {0}, {}, {0,0,1,0} }> B3_A3_____________1__; |
| 120 |
typedef B3<A3{ {0}, {}, {0,0,1} }> B3_A3_____________1__; |
| 121 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0,0}, {0,1,0} }> B3_A3____________1___; |
| 122 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0,0}, {0,1} }> B3_A3____________1___; |
| 123 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0,0}, {1} }> B3_A3___________1____; |
| 124 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0,1}, {0,0,0,0,0} }> B3_A3__________1_____; |
| 125 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0,1}, {} }> B3_A3__________1_____; |
| 126 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,0,1} }> B3_A3__________1_____; |
| 127 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,0,1,0}, {0,0,0,0,0} }> B3_A3_________1______; |
| 128 |
typedef B3<A3{ {0,0,0,0,0}, {0,0,1,0,0}, {0,0,0,0,0} }> B3_A3________1_______; |
| 129 |
typedef B3<A3{ {0,0,0,0,0}, {0,1,0,0,0}, {0,0,0,0,0} }> B3_A3_______1________; |
| 130 |
typedef B3<A3{ {0,0,0,0,0}, {1,0,0,0,0}, {0,0,0,0,0} }> B3_A3______1_________; |
| 131 |
typedef B3<A3{ {0,0,0,0,1}, {0,0,0,0,0}, {0,0,0,0,0} }> B3_A3_____1__________; |
| 132 |
typedef B3<A3{ {0,0,0,0,1}, {0,0,0,0,0} }> B3_A3_____1__________; |
| 133 |
typedef B3<A3{ {0,0,0,0,1} }> B3_A3_____1__________; |
| 134 |
typedef B3<A3{ {0,0,0,1,0}, {0,0,0,0,0}, {0,0,0,0,0} }> B3_A3____1___________; |
| 135 |
typedef B3<A3{ {0,0,1,0,0}, {0,0,0,0,0}, {0,0,0,0,0} }> B3_A3___1____________; |
| 136 |
typedef B3<A3{ {0,1,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0} }> B3_A3__1_____________; |
| 137 |
typedef B3<A3{ {1,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0} }> B3_A3_1______________; |
| 138 |
typedef B3<A3{ {1,0,0,0,0}, {0,0,0,0,0} }> B3_A3_1______________; |
| 139 |
typedef B3<A3{ {1,0,0,0,0} }> B3_A3_1______________; |
| 140 |
typedef B3<A3{ {1,0,0,0} }> B3_A3_1______________; |
| 141 |
typedef B3<A3{ {1,0,0} }> B3_A3_1______________; |
| 142 |
typedef B3<A3{ {1,0} }> B3_A3_1______________; |
| 143 |
typedef B3<A3{ {1} }> B3_A3_1______________; |
| 144 |
|
| 145 |
typedef B3<A3{ {1,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,1} }> B3_A3_1_____________1; |
| 146 |
typedef B3<A3{ {1}, {0}, {0,0,0,0,1} }> B3_A3_1_____________1; |
| 147 |
typedef B3<A3{ {1}, {}, {0,0,0,0,1} }> B3_A3_1_____________1; |
| 148 |
typedef B3<A3{ {0,1,0,0,0}, {0,0,0,0,0}, {0,0,0,1} }> B3_A3__1___________1_; |
| 149 |
typedef B3<A3{ {0,1}, {0}, {0,0,0,1} }> B3_A3__1___________1_; |
| 150 |
typedef B3<A3{ {0,1}, {}, {0,0,0,1} }> B3_A3__1___________1_; |
| 151 |
|
| 152 |
// Same as above. |
| 153 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0\0", "\0\0\0\0" }> B3_A3________________; |
| 154 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0\0", "\0\0\0" }> B3_A3________________; |
| 155 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0\0", "\0\0" }> B3_A3________________; |
| 156 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0\0", "\0" }> B3_A3________________; |
| 157 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0\0", "" }> B3_A3________________; |
| 158 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0", "" }> B3_A3________________; |
| 159 |
typedef B3<A3{ "\0\0\0\0", "\0\0", "" }> B3_A3________________; |
| 160 |
typedef B3<A3{ "\0\0\0\0", "\0", "" }> B3_A3________________; |
| 161 |
typedef B3<A3{ "\0\0\0\0", "", "" }> B3_A3________________; |
| 162 |
typedef B3<A3{ "\0\0\0", "", "" }> B3_A3________________; |
| 163 |
typedef B3<A3{ "\0\0", "", "" }> B3_A3________________; |
| 164 |
typedef B3<A3{ "\0", "", "" }> B3_A3________________; |
| 165 |
typedef B3<A3{ "", "", "" }> B3_A3________________; |
| 166 |
typedef B3<A3{ "", "" }> B3_A3________________; |
| 167 |
typedef B3<A3{ "" }> B3_A3________________; |
| 168 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0", { 0 } }> B3_A3________________; |
| 169 |
typedef B3<A3{ "\0\0", { 0 }, "\0" }> B3_A3________________; |
| 170 |
typedef B3<A3{ { 0 }, "", "\0\0\0\0" }> B3_A3________________; |
| 171 |
typedef B3<A3{ "\0\0\0", "\0\0", { } }> B3_A3________________; |
| 172 |
typedef B3<A3{ "\0", { }, "" }> B3_A3________________; |
| 173 |
typedef B3<A3{ { }, "\0\0\0\0", "\0\0\0" }> B3_A3________________; |
| 174 |
|
| 175 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0", {0,0,0,0,1} }> B3_A3_______________1; |
| 176 |
typedef B3<A3{ "\0\0", "\0", "\0\0\0\1" }> B3_A3______________1_; |
| 177 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0", "\0\0\1" }> B3_A3_____________1__; |
| 178 |
typedef B3<A3{ "\0\0", "\0", "\0\1" }> B3_A3____________1___; |
| 179 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0", "\1" }> B3_A3___________1____; |
| 180 |
typedef B3<A3{ "\0\0", {0,0,0,0,1}, "\0" }> B3_A3__________1_____; |
| 181 |
typedef B3<A3{ "\0\0\0\0", "\0\0\0\1", "\0\0\0" }> B3_A3_________1______; |
| 182 |
typedef B3<A3{ "\0\0", "\0\0\1", "\0" }> B3_A3________1_______; |
| 183 |
typedef B3<A3{ "\0\0\0\0", "\0\1", "\0\0\0" }> B3_A3_______1________; |
| 184 |
typedef B3<A3{ "\0\0", "\1", "\0" }> B3_A3______1_________; |
| 185 |
typedef B3<A3{ {0,0,0,0,1}, "\0\0\0\0", "\0\0\0" }> B3_A3_____1__________; |
| 186 |
typedef B3<A3{ "\0\0\0\1", "\0\0", "\0" }> B3_A3____1___________; |
| 187 |
typedef B3<A3{ "\0\0\1", "\0\0\0\0", "\0\0\0" }> B3_A3___1____________; |
| 188 |
typedef B3<A3{ "\0\1", "\0\0", "\0" }> B3_A3__1_____________; |
| 189 |
typedef B3<A3{ "\1", "", "\0\0\0\0" }> B3_A3_1______________; |
| 190 |
|
| 191 |
typedef B3<A3{ "\1", {}, {0,0,0,0,1} }> B3_A3_1_____________1; |
| 192 |
typedef B3<A3{ "\1", "", {0,0,0,0,1} }> B3_A3_1_____________1; |
| 193 |
typedef B3<A3{ "\0\1", {}, {0,0,0,1} }> B3_A3__1___________1_; |
| 194 |
typedef B3<A3{ "\0\1", "", "\0\0\0\1" }> B3_A3__1___________1_; |
| 195 |
typedef B3<A3{ "\0\1\0", "\0", "\0\0\0\1" }> B3_A3__1___________1_; |
| 196 |
|
| 197 |
void f_b3_a3 (B3_A3________________) { } |
| 198 |
void f_b3_a3 (B3_A3_______________1) { } |
| 199 |
void f_b3_a3 (B3_A3______________1_) { } |
| 200 |
void f_b3_a3 (B3_A3_____________1__) { } |
| 201 |
void f_b3_a3 (B3_A3____________1___) { } |
| 202 |
void f_b3_a3 (B3_A3___________1____) { } |
| 203 |
void f_b3_a3 (B3_A3__________1_____) { } |
| 204 |
void f_b3_a3 (B3_A3_________1______) { } |
| 205 |
void f_b3_a3 (B3_A3________1_______) { } |
| 206 |
void f_b3_a3 (B3_A3_______1________) { } |
| 207 |
void f_b3_a3 (B3_A3______1_________) { } |
| 208 |
void f_b3_a3 (B3_A3_____1__________) { } |
| 209 |
void f_b3_a3 (B3_A3____1___________) { } |
| 210 |
void f_b3_a3 (B3_A3___1____________) { } |
| 211 |
void f_b3_a3 (B3_A3__1_____________) { } |
| 212 |
void f_b3_a3 (B3_A3_1______________) { } |
| 213 |
void f_b3_a3 (B3_A3_1_____________1) { } |
| 214 |
void f_b3_a3 (B3_A3__1___________1_) { } |
| 215 |
|
| 216 |
typedef B3<A3{ "AB\0D", { }, "IJKL" }> B3_A3_ABZDZZZZZZIJKLZ; |
| 217 |
typedef B3<A3{ "AB\0D", { 0, 0, 1 }, "IJKL" }> B3_A3_ABZDZZZ1ZZIJKLZ; |
| 218 |
typedef B3<A3{ "AB\0D", { 0, 1 }, "IJKL" }> B3_A3_ABZDZZ1ZZZIJKLZ; |
| 219 |
|
| 220 |
void f (B3_A3_ABZDZZZZZZIJKLZ) { } |
| 221 |
void f (B3_A3_ABZDZZZ1ZZIJKLZ) { } |
| 222 |
void f (B3_A3_ABZDZZ1ZZZIJKLZ) { } |