79 lines · c
1// RUN: %clang_cc1 %s -Eonly -std=c89 -verify=undef-true2// RUN: %clang_cc1 %s -Eonly -std=c99 -verify=undef-true3// RUN: %clang_cc1 %s -Eonly -std=c11 -verify=undef-true4// RUN: %clang_cc1 %s -Eonly -std=c17 -verify=undef-true5// RUN: %clang_cc1 %s -Eonly -std=c23 -verify=undef-true6 7#if __STDC_VERSION__ >= 202311L8/* undef-true-no-diagnostics */9#endif10 11#define FOO true12#if FOO /* #1 */13#endif14#if __STDC_VERSION__ < 202311L15/* undef-true-warning@#1 {{'true' is not defined, evaluates to 0}} */16#endif17 18#if true /* #2 */19#endif20#if __STDC_VERSION__ < 202311L21/* undef-true-warning@#2 {{'true' is not defined, evaluates to 0}} */22#endif23 24#if false || true /* #3 */25#endif26#if __STDC_VERSION__ < 202311L27/* undef-true-warning@#3 {{'true' is not defined, evaluates to 0}} */28#endif29 30#define true 131 32#define FOO true33#if FOO34#endif35 36#if true37#endif38 39#if false || true40#endif41 42#undef true43 44#define FOO true45#if FOO /* #4 */46#endif47#if __STDC_VERSION__ < 202311L48/* undef-true-warning@#4 {{'true' is not defined, evaluates to 0}} */49#endif50 51#if true /* #5 */52#endif53#if __STDC_VERSION__ < 202311L54/* undef-true-warning@#5 {{'true' is not defined, evaluates to 0}} */55#endif56 57#if false || true /* #6 */58#endif59#if __STDC_VERSION__ < 202311L60/* undef-true-warning@#6 {{'true' is not defined, evaluates to 0}} */61#endif62 63#define true true64#if true /* #7 */65#endif66#if __STDC_VERSION__ < 202311L67/* undef-true-warning@#7 {{'true' is not defined, evaluates to 0}} */68#endif69#undef true70 71/* Test that #pragma-enabled 'Wundef' can override 'Wundef-true' */72#pragma clang diagnostic warning "-Wundef"73#if true /* #8 */74#endif75#pragma clang diagnostic ignored "-Wundef"76#if __STDC_VERSION__ < 202311L77/* undef-true-warning@#8 {{'true' is not defined, evaluates to 0}} */78#endif79