|
| 1 | +// RUN: %clang_cc1 -verify -Wno-unused -I %S/Inputs %s |
| 2 | + |
| 3 | +/* WG14 N590: Clang 3.2 |
| 4 | + * Increase minimum translation limits |
| 5 | + * |
| 6 | + * NB: the content of this document is not available, so this is testing |
| 7 | + * against the implementation limits in C23, which are the most aggressive |
| 8 | + * translation limits we can test against. |
| 9 | + */ |
| 10 | +// expected-no-diagnostics |
| 11 | + |
| 12 | +// 15 nesting levels for #included files |
| 13 | +// NOTE: this relies on the value of __COUNTER__, so be very careful about |
| 14 | +// adding code above this line of the test. |
| 15 | +#include "nested-include.h" |
| 16 | + |
| 17 | +// Helpers for declaring unique variables. |
| 18 | +#define CAT_IMPL(x, y) x ## y |
| 19 | +#define CAT(x, y) CAT_IMPL(x, y) |
| 20 | +#define ONCE(x) CAT(x, __COUNTER__) SEPARATOR |
| 21 | +#define REPEAT10(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) |
| 22 | +#define REPEAT63(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) ONCE(x) ONCE(x) ONCE(x) |
| 23 | +#define REPEAT100(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) |
| 24 | +#define REPEAT127(x) REPEAT100(x) REPEAT10(x) REPEAT10(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) |
| 25 | +#define REPEAT500(x) REPEAT100(x) REPEAT100(x) REPEAT100(x) REPEAT100(x) REPEAT100(x) |
| 26 | +#define REPEAT1000(x) REPEAT500(x) REPEAT500(x) |
| 27 | +#define REPEAT1023(x) REPEAT1000(x) REPEAT10(x) REPEAT10(x) ONCE(x) ONCE(x) ONCE(x) |
| 28 | +#define REPEAT4095(x) REPEAT1000(x) REPEAT1000(x) REPEAT1000(x) REPEAT1000(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) REPEAT10(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) ONCE(x) |
| 29 | + |
| 30 | +// Limits taken from C23 5.2.5.2p1. |
| 31 | +void func(void) { |
| 32 | + // 127 nesting levels of blocks |
| 33 | + {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ |
| 34 | + }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} |
| 35 | + |
| 36 | + // 12 pointer, array, and function declarators (in any combination) modifying |
| 37 | + // an arithmetic, structure, union, or void type in a declaration. |
| 38 | + void (************fp)(int foo[1][2][3][4][5][6][7][8][9][10][11][12]); |
| 39 | + |
| 40 | + // 63 nesting levels of parenthesized declarators within a full declarator. |
| 41 | + int (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((decl))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))); |
| 42 | + |
| 43 | + // 63 significant initial characters in an internal identifier or a macro |
| 44 | + // name. |
| 45 | + static int aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg; |
| 46 | + |
| 47 | + // 31 significant initial characters in an external identifier. |
| 48 | + extern int gggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjjkkkkkkkkkkllllllllllmmm; |
| 49 | + |
| 50 | + // 511 identifiers with block scope declared in one block. |
| 51 | + { |
| 52 | + #define SEPARATOR ; |
| 53 | + REPEAT500(int a) |
| 54 | + REPEAT10(int a) |
| 55 | + ONC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
| 167 | + 5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,\ |
| 168 | + 3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,\ |
| 169 | + 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4"; |
| 170 | + |
| 171 | + // 1023 case labels for a switch statement. |
| 172 | + switch (aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffggg) { |
| 173 | + #define SEPARATOR : |
| 174 | + REPEAT1023(case 0x) |
| 175 | + #undef SEPARATOR |
| 176 | + break; |
| 177 | + } |
| 178 | +} |
| 179 | + |
| 180 | +// 32767 bytes in an object. |
| 181 | +struct S { |
| 182 | + unsigned char mem[32767]; |
| 183 | +}; |
| 184 | +_Static_assert(sizeof(struct S) >= 32767, ""); |
| 185 | + |
| 186 | +// 1023 members in a single structure or union |
| 187 | +struct T { |
| 188 | +#define SEPARATOR ; |
| 189 | + REPEAT1023(int mem) |
| 190 | +#undef SEPARATOR |
| 191 | +}; |
| 192 | + |
| 193 | +// 1023 enumeration constants in a single enumeration |
| 194 | +enum E { |
| 195 | +#define SEPARATOR , |
| 196 | +REPEAT1023(e) |
| 197 | +#undef SEPARATOR |
| 198 | +}; |
| 199 | + |
| 200 | +// 127 parameters in one function definition. |
| 201 | +#define SEPARATOR , |
| 202 | +// Because the parameters are all separated by commas, we have to add a final |
| 203 | +// parameter (without a preceeding comma) to form a valid declaration. |
| 204 | +void lots_of_params(REPEAT127(int a) int last) { |
| 205 | + // 127 arguments in one function call |
| 206 | + lots_of_params(REPEAT127(0x0) 0); |
| 207 | +} |
| 208 | +#undef SEPARATOR |
| 209 | + |
| 210 | +// 63 levels of nested structure or union definitions in a single member |
| 211 | +// declaration list. |
| 212 | +struct U { |
| 213 | +#define SEPARATOR ; |
| 214 | +REPEAT63(struct { int a) |
| 215 | +REPEAT63(} mem) |
| 216 | +#undef SEPARATOR |
| 217 | +}; |
| 218 | + |
| 219 | +// 63 nesting levels of conditional inclusion |
| 220 | +#if 1 |
| 221 | +#if 1 |
| 222 | +#if 1 |
| 223 | +#if 1 |
| 224 | +#if 1 |
| 225 | +#if 1 |
| 226 | +#if 1 |
| 227 | +#if 1 |
| 228 | +#if 1 |
| 229 | +#if 1 |
| 230 | +#if 1 |
| 231 | +#if 1 |
| 232 | +#if 1 |
| 233 | +#if 1 |
| 234 | +#if 1 |
| 235 | +#if 1 |
| 236 | +#if 1 |
| 237 | +#if 1 |
| 238 | +#if 1 |
| 239 | +#if 1 |
| 240 | +#if 1 |
| 241 | +#if 1 |
| 242 | +#if 1 |
| 243 | +#if 1 |
| 244 | +#if 1 |
| 245 | +#if 1 |
| 246 | +#if 1 |
| 247 | +#if 1 |
| 248 | +#if 1 |
| 249 | +#if 1 |
| 250 | +#if 1 |
| 251 | +#if 1 |
| 252 | +#if 1 |
| 253 | +#if 1 |
| 254 | +#if 1 |
| 255 | +#if 1 |
| 256 | +#if 1 |
| 257 | +#if 1 |
| 258 | +#if 1 |
| 259 | +#if 1 |
| 260 | +#if 1 |
| 261 | +#if 1 |
| 262 | +#if 1 |
| 263 | +#if 1 |
| 264 | +#if 1 |
| 265 | +#if 1 |
| 266 | +#if 1 |
| 267 | +#if 1 |
| 268 | +#if 1 |
| 269 | +#if 1 |
| 270 | +#if 1 |
| 271 | +#if 1 |
| 272 | +#if 1 |
| 273 | +#if 1 |
| 274 | +#if 1 |
| 275 | +#if 1 |
| 276 | +#if 1 |
| 277 | +#if 1 |
| 278 | +#if 1 |
| 279 | +#if 1 |
| 280 | +#if 1 |
| 281 | +#if 1 |
| 282 | +#if 1 |
| 283 | + |
| 284 | +#endif |
| 285 | +#endif |
| 286 | +#endif |
| 287 | +#endif |
| 288 | +#endif |
| 289 | +#endif |
| 290 | +#endif |
| 291 | +#endif |
| 292 | +#endif |
| 293 | +#endif |
| 294 | +#endif |
| 295 | +#endif |
| 296 | +#endif |
| 297 | +#endif |
| 298 | +#endif |
| 299 | +#endif |
| 300 | +#endif |
| 301 | +#endif |
| 302 | +#endif |
| 303 | +#endif |
| 304 | +#endif |
| 305 | +#endif |
| 306 | +#endif |
| 307 | +#endif |
| 308 | +#endif |
| 309 | +#endif |
| 310 | +#endif |
| 311 | +#endif |
| 312 | +#endif |
| 313 | +#endif |
| 314 | +#endif |
| 315 | +#endif |
| 316 | +#endif |
| 317 | +#endif |
| 318 | +#endif |
| 319 | +#endif |
| 320 | +#endif |
| 321 | +#endif |
| 322 | +#endif |
| 323 | +#endif |
| 324 | +#endif |
| 325 | +#endif |
| 326 | +#endif |
| 327 | +#endif |
| 328 | +#endif |
| 329 | +#endif |
| 330 | +#endif |
| 331 | +#endif |
| 332 | +#endif |
| 333 | +#endif |
| 334 | +#endif |
| 335 | +#endif |
| 336 | +#endif |
| 337 | +#endif |
| 338 | +#endif |
| 339 | +#endif |
| 340 | +#endif |
| 341 | +#endif |
| 342 | +#endif |
| 343 | +#endif |
| 344 | +#endif |
| 345 | +#endif |
| 346 | +#endif |
| 347 | + |
| 348 | +// 63 initial characters in a macro name. |
| 349 | +#define AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEFFFFFFFFFFGGG |
| 350 | + |
| 351 | +// 4095 external identifiers in one translation unit. |
| 352 | +#define SEPARATOR ; |
| 353 | +REPEAT4095(extern int val) |
| 354 | +#undef SEPARATOR |
| 355 | + |
| 356 | +// 127 parameters in one macro definition |
| 357 | +#define BIG_UN(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, \ |
| 358 | + a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, \ |
| 359 | + a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, \ |
| 360 | + a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, \ |
| 361 | + a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, \ |
| 362 | + a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, \ |
| 363 | + a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, \ |
| 364 | + a70, a71, a72, a73, a74, a75, a76, a77, a78, a79, \ |
| 365 | + a80, a81, a82, a83, a84, a85, a86, a87, a88, a89, \ |
| 366 | + a90, a91, a92, a93, a94, a95, a96, a97, a98, a99, \ |
| 367 | + a100, a101, a102, a103, a104, a105, a106, a107, a108, a109, \ |
| 368 | + a110, a111, a112, a113, a114, a115, a116, a117, a118, a119, \ |
| 369 | + a120, a121, a122, a123, a124, a125, a126) 0 |
| 370 | + |
| 371 | +// 127 arguments in one macro invocation |
| 372 | +int val = BIG_UN(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \ |
| 373 | + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \ |
| 374 | + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, \ |
| 375 | + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, \ |
| 376 | + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, \ |
| 377 | + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, \ |
| 378 | + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, \ |
| 379 | + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, \ |
| 380 | + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, \ |
| 381 | + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, \ |
| 382 | + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, \ |
| 383 | + 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, \ |
| 384 | + 120, 121, 122, 123, 124, 125, 126); |
| 385 | + |
| 386 | +// 4095 macro identifiers simultaneously defined in one preprocessing |
| 387 | +// translation unit. Rather than write out 4095 macro definitions, we'll use a |
| 388 | +// cheap python script to generate the contents and test that. |
| 389 | +// RUN: %python -c "print('\n'.join(['// expected-no-diagnostics'] + [f'#define M{i}\n' for i in range(4096)]))" >%t.inc |
| 390 | +// RUN: %clang_cc1 -verify %t.inc |
0 commit comments