91 lines · c
1// RUN: %clang_cc1 -verify -ffreestanding %s2 3/* WG14 ???: yes4 * restricted character set support via digraphs and <iso646.h>5 *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 is9 * referring to features added by AMD1 to support ISO 646 and digraphs.10 */11 12// Validate that we provide iso646.h in freestanding mode.13#include <iso646.h>14 15// Validate that we define all the expected macros and their expected16// expansions (when suitable for a constant expression) as well.17#ifndef and18#error "missing and"19#else20_Static_assert((1 and 1) == (1 && 1), "");21#endif22 23#ifndef and_eq24#error "missing and_eq"25#endif26 27#ifndef bitand28#error "missing bitand"29#else30_Static_assert((1 bitand 3) == (1 & 3), "");31#endif32 33#ifndef bitor34#error "missing bitor"35#else36_Static_assert((1 bitor 2) == (1 | 2), "");37#endif38 39#ifndef compl40#error "missing compl"41#else42_Static_assert((compl 0) == (~0), "");43#endif44 45#ifndef not46#error "missing not"47#else48_Static_assert((not 12) == (!12), "");49#endif50 51#ifndef not_eq52#error "missing not_eq"53#else54_Static_assert((0 not_eq 12) == (0 != 12), "");55#endif56 57#ifndef or58#error "missing or"59#else60// This intentionally diagnoses use of '||' only, because the user likely did61// 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#endif65 66#ifndef or_eq67#error "missing or_eq"68#endif69 70#ifndef xor71#error "missing xor"72#else73_Static_assert((1 xor 3) == (1 ^ 3), "");74#endif75 76#ifndef xor_eq77#error "missing xor_eq"78#endif79 80// Validate that digraphs behave the same as their expected counterparts. The81// definition should match the declaration in every way except spelling.82#define DI_NAME(f, b) f %:%: b83#define STD_NAME(f, b) f ## b84void DI_NAME(foo, bar)(int (*array)<: 0 :>);85void STD_NAME(foo, bar)(int (*array)[0]) {}86 87#define DI_STR(f) %:f88#define STD_STR(f) #f89_Static_assert(__builtin_strcmp(DI_STR(testing), STD_STR(testing)) == 0, "");90 91