brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · d71a3f3 Raw
39 lines · c
1// RUN: %clang_cc1 -verify=ext -std=c23 -pedantic %s2// RUN: %clang_cc1 -verify=ext -pedantic -x c++ %s3// RUN: %clang_cc1 -verify=pre -std=c2y -pedantic -Wpre-c2y-compat %s4 5/* WG14 N3457: Clang 226 * The __COUNTER__ predefined macro7 *8 * This predefined macro was supported as an extension in earlier versions of9 * Clang, but the required diagnostics for the limits were not added until 22.10 */11 12// Ensure that __COUNTER__ starts from 0.13static_assert(__COUNTER__ == 0); /* ext-warning {{'__COUNTER__' is a C2y extension}}14                                    pre-warning {{'__COUNTER__' is incompatible with standards before C2y}}15                                  */16 17// Ensure that the produced value can be used with token concatenation.18#define CAT_IMPL(a, b) a ## b19#define CAT(a, b) CAT_IMPL(a, b)20#define NAME_WITH_COUNTER(a) CAT(a, __COUNTER__)21void test() {22  // Because this is the 2nd expansion, this defines test1.23  int NAME_WITH_COUNTER(test); /* ext-warning {{'__COUNTER__' is a C2y extension}}24                                  pre-warning {{'__COUNTER__' is incompatible with standards before C2y}}25                                */26  int other_test = test1;      // Ok27}28 29// Ensure that __COUNTER__ increments each time you mention it.30static_assert(__COUNTER__ == 2); /* ext-warning {{'__COUNTER__' is a C2y extension}}31                                    pre-warning {{'__COUNTER__' is incompatible with standards before C2y}}32                                 */33static_assert(__COUNTER__ == 3); /* ext-warning {{'__COUNTER__' is a C2y extension}}34                                    pre-warning {{'__COUNTER__' is incompatible with standards before C2y}}35                                 */36static_assert(__COUNTER__ == 4); /* ext-warning {{'__COUNTER__' is a C2y extension}}37                                    pre-warning {{'__COUNTER__' is incompatible with standards before C2y}}38                                 */39