43 lines · c
1// RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s2// RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s -fexperimental-new-constant-interpreter3 4_Static_assert(_Generic(true, _Bool : 1, default: 0));5_Static_assert(_Generic(false, _Bool : 1, default: 0));6 7_Static_assert(_Generic(true, bool : 1, default: 0));8_Static_assert(_Generic(false, bool : 1, default: 0));9 10_Static_assert(_Generic(true, bool : true, default: false));11_Static_assert(_Generic(false, bool : true, default: false));12 13_Static_assert(true == (bool)+1);14_Static_assert(false == (bool)+0);15 16_Static_assert(_Generic(+true, bool : 0, unsigned int : 0, signed int : 1, default : 0));17 18struct S {19 bool b : 1;20} s;21_Static_assert(_Generic(+s.b, bool : 0, unsigned int : 0, signed int : 1, default : 0));22 23static void *f = false; // expected-warning {{to null from a constant boolean expression}}24static int one = true;25static int zero = false;26 27static void do_work() {28 char *str = "Foo";29 str[false] = 'f';30 str[true] = 'f';31 32 char c1[true];33 char c2[false];34}35 36#if true != 137#error true should be 1 in the preprocessor38#endif39 40#if false != 041#error false should be 0 in the preprocessor42#endif43