Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -3245,7 +3245,7 @@ Opts.RenderScript = IK.getLanguage() == Language::RenderScript; // OpenCL and C++ both have bool, true, false keywords. - Opts.Bool = Opts.OpenCL || Opts.CPlusPlus; + Opts.Bool = Opts.OpenCL || Opts.CPlusPlus || Opts.C2x; // OpenCL has half keyword Opts.Half = Opts.OpenCL; Index: clang/test/Sema/c2x-bool.c =================================================================== --- /dev/null +++ clang/test/Sema/c2x-bool.c @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c2x -x c -fsyntax-only -verify %s + +_Static_assert(_Generic(true, _Bool : 1, default: 0)); +_Static_assert(_Generic(false, _Bool : 1, default: 0)); + +_Static_assert(_Generic(true, bool : 1, default: 0)); +_Static_assert(_Generic(false, bool : 1, default: 0)); + +_Static_assert(_Generic(true, bool : true, default: false)); +_Static_assert(_Generic(false, bool : true, default: false)); + +_Static_assert(true == (bool)+1); +_Static_assert(false == (bool)+0); + + +static void *f = false; // expected-warning {{to null from a constant boolean expression}} +static int one = true; +static int zero = false; + +static void do_work() { + char *str = "Foo"; + str[0] = 'f'; + str[true] = 'f'; // TODO: This should warn(?) +}