Hi! In C23, the primary boolean spelling is bool rather than _Bool, which is just a backward compatibility thing. So, we shouldn't spell the type as _Bool in debug info (and in diagnostics) but as bool. Obviously, for C17 and earlier it should be _Bool.
The following patch does that. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2026-06-29 Jakub Jelinek <[email protected]> PR c/125935 * c-decl.cc (c_init_decl_processing): Use "bool" rather than "_Bool" as the name of boolean_type_node for C23+. * gcc.dg/debug/dwarf2/pr125935-1.c: New test. * gcc.dg/debug/dwarf2/pr125935-2.c: New test. * gcc.dg/debug/dwarf2/pr125935-3.c: New test. * gcc.dg/debug/ctf/ctf-bitfields-3.c: Expect bool rather than _Bool. * gcc.dg/Warray-bounds-65.c: Expect bool in diagnostics instead of _Bool. * gcc.dg/Wbad-function-cast-1.c: Likewise. --- gcc/c/c-decl.cc.jj 2026-06-05 07:33:07.024408163 +0200 +++ gcc/c/c-decl.cc 2026-06-26 09:58:12.058424056 +0200 @@ -4957,7 +4957,8 @@ c_init_decl_processing (void) truthvalue_false_node = integer_zero_node; /* Even in C99, which has a real boolean type. */ - pushdecl (build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("_Bool"), + pushdecl (build_decl (UNKNOWN_LOCATION, TYPE_DECL, + get_identifier (flag_isoc23 ? "bool" : "_Bool"), boolean_type_node)); /* C-specific nullptr initialization. */ --- gcc/testsuite/gcc.dg/debug/dwarf2/pr125935-1.c.jj 2026-06-26 12:29:03.369746131 +0200 +++ gcc/testsuite/gcc.dg/debug/dwarf2/pr125935-1.c 2026-06-26 12:28:59.483793100 +0200 @@ -0,0 +1,8 @@ +/* PR c/125935 */ +/* { dg-do compile } */ +/* { dg-options "-std=c17 -g -dA" } */ + +_Bool x; + +/* { dg-final { scan-assembler-times "(DW_AT_name: \"_Bool\"|\"_Bool..\"\[^\\r\\n\]*DW_AT_name)" 1 } } */ +/* { dg-final { scan-assembler-not "(DW_AT_name: \"bool\"|\"bool..\"\[^\\r\\n\]*DW_AT_name)" } } */ --- gcc/testsuite/gcc.dg/debug/dwarf2/pr125935-2.c.jj 2026-06-26 12:29:32.330396100 +0200 +++ gcc/testsuite/gcc.dg/debug/dwarf2/pr125935-2.c 2026-06-26 12:29:28.111447092 +0200 @@ -0,0 +1,8 @@ +/* PR c/125935 */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -g -dA" } */ + +_Bool x; + +/* { dg-final { scan-assembler-not "(DW_AT_name: \"_Bool\"|\"_Bool..\"\[^\\r\\n\]*DW_AT_name)" } } */ +/* { dg-final { scan-assembler-times "(DW_AT_name: \"bool\"|\"bool..\"\[^\\r\\n\]*DW_AT_name)" 1 } } */ --- gcc/testsuite/gcc.dg/debug/dwarf2/pr125935-3.c.jj 2026-06-26 12:29:37.973327898 +0200 +++ gcc/testsuite/gcc.dg/debug/dwarf2/pr125935-3.c 2026-06-26 12:29:42.951267734 +0200 @@ -0,0 +1,8 @@ +/* PR c/125935 */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -g -dA" } */ + +bool x; + +/* { dg-final { scan-assembler-not "(DW_AT_name: \"_Bool\"|\"_Bool..\"\[^\\r\\n\]*DW_AT_name)" } } */ +/* { dg-final { scan-assembler-times "(DW_AT_name: \"bool\"|\"bool..\"\[^\\r\\n\]*DW_AT_name)" 1 } } */ --- gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-3.c.jj 2024-09-24 15:14:54.131161835 +0200 +++ gcc/testsuite/gcc.dg/debug/ctf/ctf-bitfields-3.c 2026-06-26 13:39:57.869263872 +0200 @@ -6,7 +6,7 @@ /* { dg-final { scan-assembler-times "\[\t \]0x2\[\t \]+\[^\n\]*cts_type" 2 } } */ /* { dg-final { scan-assembler-times "\[\t \]0x1\[\t \]+\[^\n\]*cts_bits" 2 } } */ -/* { dg-final { scan-assembler-times "ascii \"_Bool.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */ +/* { dg-final { scan-assembler-times "ascii \"bool.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */ #include <stdbool.h> --- gcc/testsuite/gcc.dg/Warray-bounds-65.c.jj 2020-09-21 23:15:16.710050359 +0200 +++ gcc/testsuite/gcc.dg/Warray-bounds-65.c 2026-06-26 13:40:42.373725508 +0200 @@ -31,11 +31,11 @@ test_note (int (*pia3)[3]) // { dg-me void test_a1_cst (_Bool (*pba0)[0], char (*pca1)[1], short (*psa2)[2], int (*pia3)[3]) { - T ((*pba0)[-1]); // { dg-warning "array subscript -1 is (above|outside) array bounds of '_Bool\\\[0]'" } - T ((*pba0)[0]); // { dg-warning "array subscript 0 is (above|outside) array bounds of '_Bool\\\[0]'" } - T ((*pba0)[1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of '_Bool\\\[0]'" } - T ((*pba0)[2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of '_Bool\\\[0]'" } - T ((*pba0)[12]); // { dg-warning "array subscript 12 is (above|outside) array bounds of '_Bool\\\[0]'" } + T ((*pba0)[-1]); // { dg-warning "array subscript -1 is (above|outside) array bounds of 'bool\\\[0]'" } + T ((*pba0)[0]); // { dg-warning "array subscript 0 is (above|outside) array bounds of 'bool\\\[0]'" } + T ((*pba0)[1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of 'bool\\\[0]'" } + T ((*pba0)[2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of 'bool\\\[0]'" } + T ((*pba0)[12]); // { dg-warning "array subscript 12 is (above|outside) array bounds of 'bool\\\[0]'" } T ((*pca1)[-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of 'char\\\[1]'" } T ((*pca1)[0]); @@ -61,20 +61,20 @@ void test_a1_cst (_Bool (*pba0)[0], char void test_a2_cst (_Bool (*pba0_1)[0][1], char (*pca1_2)[1][2], short (*psa2_3)[2][3], int (*pia3_4)[3][4]) { - T ((*pba0_1)[-1][-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of '_Bool\\\[1]'" } - T ((*pba0_1)[-1][0]); // { dg-warning "array subscript -1 is (above|outside) array bounds of '_Bool\\\[0]\\\[1]'" } + T ((*pba0_1)[-1][-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of 'bool\\\[1]'" } + T ((*pba0_1)[-1][0]); // { dg-warning "array subscript -1 is (above|outside) array bounds of 'bool\\\[0]\\\[1]'" } - T ((*pba0_1)[0][-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of '_Bool\\\[1]'" } - T ((*pba0_1)[0][0]); // { dg-warning "array subscript 0 is (above|outside) array bounds of '_Bool\\\[0]\\\[1]'" } - T ((*pba0_1)[0][1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of '_Bool\\\[1]'" } - T ((*pba0_1)[0][2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of '_Bool\\\[1]'" } - T ((*pba0_1)[0][12]); // { dg-warning "array subscript 12 is (above|outside) array bounds of '_Bool\\\[1]'" } - - T ((*pba0_1)[1][-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of '_Bool\\\[1]'" } - T ((*pba0_1)[1][0]); // { dg-warning "array subscript 1 is (above|outside) array bounds of '_Bool\\\[0]\\\[1]'" } - T ((*pba0_1)[1][1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of '_Bool\\\[1]'" } - T ((*pba0_1)[1][2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of '_Bool\\\[1]'" } - T ((*pba0_1)[1][12]); // { dg-warning "array subscript 12 is (above|outside) array bounds of '_Bool\\\[1]'" } + T ((*pba0_1)[0][-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of 'bool\\\[1]'" } + T ((*pba0_1)[0][0]); // { dg-warning "array subscript 0 is (above|outside) array bounds of 'bool\\\[0]\\\[1]'" } + T ((*pba0_1)[0][1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of 'bool\\\[1]'" } + T ((*pba0_1)[0][2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of 'bool\\\[1]'" } + T ((*pba0_1)[0][12]); // { dg-warning "array subscript 12 is (above|outside) array bounds of 'bool\\\[1]'" } + + T ((*pba0_1)[1][-1]); // { dg-warning "array subscript -1 is (below|outside) array bounds of 'bool\\\[1]'" } + T ((*pba0_1)[1][0]); // { dg-warning "array subscript 1 is (above|outside) array bounds of 'bool\\\[0]\\\[1]'" } + T ((*pba0_1)[1][1]); // { dg-warning "array subscript 1 is (above|outside) array bounds of 'bool\\\[1]'" } + T ((*pba0_1)[1][2]); // { dg-warning "array subscript 2 is (above|outside) array bounds of 'bool\\\[1]'" } + T ((*pba0_1)[1][12]); // { dg-warning "array subscript 12 is (above|outside) array bounds of 'bool\\\[1]'" } T ((*pca1_2)[0][0]); --- gcc/testsuite/gcc.dg/Wbad-function-cast-1.c.jj 2020-01-14 20:02:47.203603542 +0100 +++ gcc/testsuite/gcc.dg/Wbad-function-cast-1.c 2026-06-26 13:41:09.042402900 +0200 @@ -40,12 +40,12 @@ foo(void) types. */ (float)if1(); /* { dg-warning "cast from function call of type 'int' to non-matching type 'float'" } */ (double)if2(); /* { dg-warning "cast from function call of type 'char' to non-matching type 'double'" } */ - (_Bool)if3(); /* { dg-warning "cast from function call of type 'long int' to non-matching type '_Bool'" } */ + (_Bool)if3(); /* { dg-warning "cast from function call of type 'long int' to non-matching type 'bool'" } */ (int)rf1(); /* { dg-warning "cast from function call of type 'float' to non-matching type 'int'" } */ (long)rf2(); /* { dg-warning "cast from function call of type 'double' to non-matching type 'long int'" } */ (double)cf(); /* { dg-warning "cast from function call of type 'complex double' to non-matching type 'double'" } */ (int)ef(); /* { dg-warning "cast from function call of type 'enum e' to non-matching type 'int'" } */ - (int)bf(); /* { dg-warning "cast from function call of type '_Bool' to non-matching type 'int'" } */ + (int)bf(); /* { dg-warning "cast from function call of type 'bool' to non-matching type 'int'" } */ (__SIZE_TYPE__)pf1(); /* { dg-warning "cast from function call of type 'char \\*' to non-matching type '\[^\\n\]*'" } */ (__PTRDIFF_TYPE__)pf2(); /* { dg-warning "cast from function call of type 'int \\*' to non-matching type '\[^\\n\]*'" } */ } Jakub
