1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
// RUN: %clang_cc1 %s -Eonly -std=c89 -verify=undef-true
// RUN: %clang_cc1 %s -Eonly -std=c99 -verify=undef-true
// RUN: %clang_cc1 %s -Eonly -std=c11 -verify=undef-true
// RUN: %clang_cc1 %s -Eonly -std=c17 -verify=undef-true
// RUN: %clang_cc1 %s -Eonly -std=c23 -verify=undef-true
#if __STDC_VERSION__ >= 202311L
/* undef-true-no-diagnostics */
#endif
#define FOO true
#if FOO /* #1 */
#endif
#if __STDC_VERSION__ < 202311L
/* undef-true-warning@#1 {{'true' is not defined, evaluates to 0}} */
#endif
#if true /* #2 */
#endif
#if __STDC_VERSION__ < 202311L
/* undef-true-warning@#2 {{'true' is not defined, evaluates to 0}} */
#endif
#if false || true /* #3 */
#endif
#if __STDC_VERSION__ < 202311L
/* undef-true-warning@#3 {{'true' is not defined, evaluates to 0}} */
#endif
#define true 1
#define FOO true
#if FOO
#endif
#if true
#endif
#if false || true
#endif
#undef true
#define FOO true
#if FOO /* #4 */
#endif
#if __STDC_VERSION__ < 202311L
/* undef-true-warning@#4 {{'true' is not defined, evaluates to 0}} */
#endif
#if true /* #5 */
#endif
#if __STDC_VERSION__ < 202311L
/* undef-true-warning@#5 {{'true' is not defined, evaluates to 0}} */
#endif
#if false || true /* #6 */
#endif
#if __STDC_VERSION__ < 202311L
/* undef-true-warning@#6 {{'true' is not defined, evaluates to 0}} */
#endif
#define true true
#if true /* #7 */
#endif
#if __STDC_VERSION__ < 202311L
/* undef-true-warning@#7 {{'true' is not defined, evaluates to 0}} */
#endif
#undef true
/* Test that #pragma-enabled 'Wundef' can override 'Wundef-true' */
#pragma clang diagnostic warning "-Wundef"
#if true /* #8 */
#endif
#pragma clang diagnostic ignored "-Wundef"
#if __STDC_VERSION__ < 202311L
/* undef-true-warning@#8 {{'true' is not defined, evaluates to 0}} */
#endif
|