[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / Sema / c2x-bool.c
blob98cb8507359d0fb099863cb1991464d8fb5caead
1 // RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s -fexperimental-new-constant-interpreter
4 _Static_assert(_Generic(true, _Bool : 1, default: 0));
5 _Static_assert(_Generic(false, _Bool : 1, default: 0));
7 _Static_assert(_Generic(true, bool : 1, default: 0));
8 _Static_assert(_Generic(false, bool : 1, default: 0));
10 _Static_assert(_Generic(true, bool : true, default: false));
11 _Static_assert(_Generic(false, bool : true, default: false));
13 _Static_assert(true == (bool)+1);
14 _Static_assert(false == (bool)+0);
16 _Static_assert(_Generic(+true, bool : 0, unsigned int : 0, signed int : 1, default : 0));
18 struct S {
19 bool b : 1;
20 } s;
21 _Static_assert(_Generic(+s.b, bool : 0, unsigned int : 0, signed int : 1, default : 0));
23 static void *f = false; // expected-warning {{to null from a constant boolean expression}}
24 static int one = true;
25 static int zero = false;
27 static void do_work() {
28 char *str = "Foo";
29 str[false] = 'f';
30 str[true] = 'f';
32 char c1[true];
33 char c2[false];
36 #if true != 1
37 #error true should be 1 in the preprocessor
38 #endif
40 #if false != 0
41 #error false should be 0 in the preprocessor
42 #endif