1 // RUN: %clang_cc1 -verify -ffreestanding %s
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.
15 // Validate that we define all the expected macros and their expected
16 // expansions (when suitable for a constant expression) as well.
20 _Static_assert((1 and 1) == (1 && 1), "");
24 #error "missing and_eq"
28 #error "missing bitand"
30 _Static_assert((1 bitand 3) == (1 & 3), "");
34 #error "missing bitor"
36 _Static_assert((1 bitor 2) == (1 | 2), "");
40 #error "missing compl"
42 _Static_assert((compl 0) == (~0), "");
48 _Static_assert((not 12) == (!12), "");
52 #error "missing not_eq"
54 _Static_assert((0 not_eq 12) == (0 != 12), "");
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
}}
67 #error "missing or_eq"
73 _Static_assert((1 xor 3) == (1 ^ 3), "");
77 #error "missing xor_eq"
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]) {}
89 _Static_assert(__builtin_strcmp(DI_STR(testing
), STD_STR(testing
)) == 0, "");