Make test more lenient for custom clang version strings
[llvm-project.git] / clang / test / C / C99 / digraphs.c
blob870a441118161af9d05f8b868d6555af52c57c08
1 // RUN: %clang_cc1 -verify -ffreestanding %s
3 /* WG14 ???: yes
4 * restricted character set support via digraphs and <iso646.h>
6 * NB: I cannot find a definitive document number associated with the feature,
7 * which was pulled from the editor's report in the C99 front matter. However,
8 * based on discussion in the C99 rationale document, I believe this is
9 * referring to features added by AMD1 to support ISO 646 and digraphs.
12 // Validate that we provide iso646.h in freestanding mode.
13 #include <iso646.h>
15 // Validate that we define all the expected macros and their expected
16 // expansions (when suitable for a constant expression) as well.
17 #ifndef and
18 #error "missing and"
19 #else
20 _Static_assert((1 and 1) == (1 && 1), "");
21 #endif
23 #ifndef and_eq
24 #error "missing and_eq"
25 #endif
27 #ifndef bitand
28 #error "missing bitand"
29 #else
30 _Static_assert((1 bitand 3) == (1 & 3), "");
31 #endif
33 #ifndef bitor
34 #error "missing bitor"
35 #else
36 _Static_assert((1 bitor 2) == (1 | 2), "");
37 #endif
39 #ifndef compl
40 #error "missing compl"
41 #else
42 _Static_assert((compl 0) == (~0), "");
43 #endif
45 #ifndef not
46 #error "missing not"
47 #else
48 _Static_assert((not 12) == (!12), "");
49 #endif
51 #ifndef not_eq
52 #error "missing not_eq"
53 #else
54 _Static_assert((0 not_eq 12) == (0 != 12), "");
55 #endif
57 #ifndef or
58 #error "missing or"
59 #else
60 // This intentionally diagnoses use of '||' only, because the user likely did
61 // not confuse the operator when using 'or' instead.
62 _Static_assert((0 or 12) == (0 || 12), ""); // expected-warning {{use of logical '||' with constant operand}} \
63 expected-note {{use '|' for a bitwise operation}}
64 #endif
66 #ifndef or_eq
67 #error "missing or_eq"
68 #endif
70 #ifndef xor
71 #error "missing xor"
72 #else
73 _Static_assert((1 xor 3) == (1 ^ 3), "");
74 #endif
76 #ifndef xor_eq
77 #error "missing xor_eq"
78 #endif
80 // Validate that digraphs behave the same as their expected counterparts. The
81 // definition should match the declaration in every way except spelling.
82 #define DI_NAME(f, b) f %:%: b
83 #define STD_NAME(f, b) f ## b
84 void DI_NAME(foo, bar)(int (*array)<: 0 :>);
85 void STD_NAME(foo, bar)(int (*array)[0]) {}
87 #define DI_STR(f) %:f
88 #define STD_STR(f) #f
89 _Static_assert(__builtin_strcmp(DI_STR(testing), STD_STR(testing)) == 0, "");