diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index 127f9553e0c087c57aa12048f1a40702b0318e7a..3f2cabf9448f8e631bc57c36927229b9e60f4c41 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -261,8 +261,8 @@ c_common_init_options (unsigned int decoded_options_count, if (c_language == clk_c) { - /* The default for C is gnu17. */ - set_std_c17 (false /* ISO */); + /* The default for C is gnu23. */ + set_std_c23 (false /* ISO */); /* If preprocessing assembly language, accept any of the C-family front end options since the driver may pass them through. */ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 36d79d1c76bfbf9ce3b5073260eed559a96b423e..929feaf23fbbdad5866ebc62effd69c165e0504c 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2501,11 +2501,12 @@ The name @samp{gnu1x} is deprecated. @item gnu17 @itemx gnu18 -GNU dialect of ISO C17. This is the default for C code. +GNU dialect of ISO C17. @item gnu23 @itemx gnu2x -GNU dialect of ISO C23. The name @samp{gnu2x} is deprecated. +GNU dialect of ISO C23. This is the default for C code. The name +@samp{gnu2x} is deprecated. @item gnu2y The next version of the ISO C standard, still under development, plus diff --git a/gcc/testsuite/c-c++-common/analyzer/asm-x86-dyndbg-2.c b/gcc/testsuite/c-c++-common/analyzer/asm-x86-dyndbg-2.c index d5e748c9acd7334df3474a6c9a3f35ce5223e1e5..db77ce9a4f96ba724b17fcd696bab61de5f5fbaa 100644 --- a/gcc/testsuite/c-c++-common/analyzer/asm-x86-dyndbg-2.c +++ b/gcc/testsuite/c-c++-common/analyzer/asm-x86-dyndbg-2.c @@ -8,12 +8,6 @@ /* Adapted from various files in the Linux kernel, all of which have: */ /* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __cplusplus - typedef _Bool bool; - #define true 1 - #define false 0 -#endif - typedef struct {} atomic_t; /* Adapted from include/linux/compiler_attributes.h */ diff --git a/gcc/testsuite/c-c++-common/analyzer/asm-x86-lp64-2.c b/gcc/testsuite/c-c++-common/analyzer/asm-x86-lp64-2.c index 37c487a69c267f6ba1fec3ee1cc8a7911ddb42d3..5d32c9a66c3ce6afe86574457f12da5d8a53b5b3 100644 --- a/gcc/testsuite/c-c++-common/analyzer/asm-x86-lp64-2.c +++ b/gcc/testsuite/c-c++-common/analyzer/asm-x86-lp64-2.c @@ -3,10 +3,6 @@ /* Adapted from Linux x86: page_ref_dec_and_test.c (GPL-2.0). */ -#ifndef __cplusplus - typedef _Bool bool; -#endif - typedef struct { int counter; } atomic_t; diff --git a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c index 24fb46bd5a9bf11f8bf44c2881336141613ca732..87ad42a3c3286b28e4712de92d4af089412cedc3 100644 --- a/gcc/testsuite/c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c +++ b/gcc/testsuite/c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c @@ -4,10 +4,6 @@ typedef unsigned char u8; typedef unsigned short u16; -#ifndef __cplusplus - typedef _Bool bool; -#endif - #define ENOMEM 12 #define EINVAL 22 diff --git a/gcc/testsuite/c-c++-common/analyzer/coreutils-cksum-pr108664.c b/gcc/testsuite/c-c++-common/analyzer/coreutils-cksum-pr108664.c index 7ae4e6b06bea96842957c4922674af2f5510c766..67dcbce09d045417b288e82a5d65d98d4b3f602d 100644 --- a/gcc/testsuite/c-c++-common/analyzer/coreutils-cksum-pr108664.c +++ b/gcc/testsuite/c-c++-common/analyzer/coreutils-cksum-pr108664.c @@ -8,10 +8,6 @@ typedef unsigned int __uint32_t; typedef unsigned long int __uintmax_t; typedef struct _IO_FILE FILE; -#ifndef __cplusplus - typedef _Bool bool; -#endif - extern size_t fread_unlocked(void* __restrict __ptr, size_t __size, diff --git a/gcc/testsuite/c-c++-common/analyzer/feasibility-3.c b/gcc/testsuite/c-c++-common/analyzer/feasibility-3.c index 06194f85069cec2a838a5b38f5b4cf5308e4cba3..06aed88b5e8d37e1d536ae54a228f260e6295115 100644 --- a/gcc/testsuite/c-c++-common/analyzer/feasibility-3.c +++ b/gcc/testsuite/c-c++-common/analyzer/feasibility-3.c @@ -6,9 +6,6 @@ /* Types. */ typedef unsigned char u8; -#ifndef __cplusplus -typedef _Bool bool; -#endif typedef unsigned int gfp_t; struct file; diff --git a/gcc/testsuite/c-c++-common/analyzer/pr105783.c b/gcc/testsuite/c-c++-common/analyzer/pr105783.c index f17519415cef4365a5314c49722e9fc29b35788a..34d21c62aef3cfa1817bfc3a351c6afeb3c12b6d 100644 --- a/gcc/testsuite/c-c++-common/analyzer/pr105783.c +++ b/gcc/testsuite/c-c++-common/analyzer/pr105783.c @@ -1,9 +1,5 @@ /* { dg-additional-options "-O" } */ -#ifndef __cplusplus -typedef _Bool bool; -#endif - struct ss_s { union out_or_counting_u { char *newstr; diff --git a/gcc/testsuite/c-c++-common/analyzer/sock-1.c b/gcc/testsuite/c-c++-common/analyzer/sock-1.c index e5e2f23bba0c74f2ad9507058a00f00a9f4f5d32..57938c0c0ab3a90c8bf4a7996378dd7f8dd6a576 100644 --- a/gcc/testsuite/c-c++-common/analyzer/sock-1.c +++ b/gcc/testsuite/c-c++-common/analyzer/sock-1.c @@ -5,9 +5,6 @@ typedef __u32 u32; typedef __s64 s64; typedef __u64 u64; typedef long long __kernel_time64_t; -#ifndef __cplusplus -typedef _Bool bool; -#endif typedef __s64 time64_t; struct __kernel_timespec { __kernel_time64_t tv_sec; diff --git a/gcc/testsuite/c-c++-common/attributes-4.c b/gcc/testsuite/c-c++-common/attributes-4.c index 55661eb792c934773e8ee11689ca30a3fc12bcad..d78cdae2e114cd6ef45a66a4abf1c2b12f00c20f 100644 --- a/gcc/testsuite/c-c++-common/attributes-4.c +++ b/gcc/testsuite/c-c++-common/attributes-4.c @@ -11,7 +11,6 @@ typedef __CHAR16_TYPE__ char16_t; typedef __CHAR32_TYPE__ char32_t; #elif !__cplusplus -typedef _Bool bool; typedef __CHAR16_TYPE__ char16_t; typedef __CHAR32_TYPE__ char32_t; typedef __WCHAR_TYPE__ wchar_t; diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-78.c b/gcc/testsuite/gcc.dg/Warray-bounds-78.c index 73c335fd8a6bac83e2c9aa6c70894c1d429bd511..26b8a9bf9feb171a482a8059707f42309c71cc35 100644 --- a/gcc/testsuite/gcc.dg/Warray-bounds-78.c +++ b/gcc/testsuite/gcc.dg/Warray-bounds-78.c @@ -3,8 +3,6 @@ { dg-do compile } { dg-options "-O2 -Wall -Wno-strict-aliasing" } */ -typedef _Bool bool; - #define NOIPA __attribute__ ((noipa)) struct S { }; diff --git a/gcc/testsuite/gcc.dg/analyzer/asm-x86-dyndbg-1.c b/gcc/testsuite/gcc.dg/analyzer/asm-x86-dyndbg-1.c index cce3f6b80bcdd5fea8b6e7b0586915b1c2bdf199..9ea86206fd8070c6d42581ffc0b2d8151a50e120 100644 --- a/gcc/testsuite/gcc.dg/analyzer/asm-x86-dyndbg-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/asm-x86-dyndbg-1.c @@ -8,10 +8,6 @@ /* Adapted from various files in the Linux kernel, all of which have: */ /* SPDX-License-Identifier: GPL-2.0 */ -typedef _Bool bool; -#define true 1 -#define false 0 - typedef struct { int counter; } atomic_t; diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-2.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-2.c index 80b9c188ceed547c8431d477d84237bb8103159a..55c73873a84d47f5b3646060fc6a6075a98b0d41 100644 --- a/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-2.c +++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-function-pointers-2.c @@ -4,7 +4,7 @@ different function pointer types. */ /* { dg-do compile } */ -/* { dg-options "-O0 -gctf -dA" } */ +/* { dg-options "-O0 -gctf -dA -std=gnu17" } */ /* { dg-final { scan-assembler-times "\[\t \]0x16000001\[\t \]+\[^\n\]*ctt_info" 1 } } */ /* { dg-final { scan-assembler-times "ascii \"rcu_callback_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */ /* { dg-final { scan-assembler-times "ascii \"func.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */ diff --git a/gcc/testsuite/gcc.dg/gnu23-version-2.c b/gcc/testsuite/gcc.dg/gnu23-version-2.c new file mode 100644 index 0000000000000000000000000000000000000000..008f445ecdf1c3a7c9e25d162c0e98b011079d68 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu23-version-2.c @@ -0,0 +1,11 @@ +/* Test __STDC_VERSION__ for C23 with GNU extensions. Test that -std=gnu23 is + the default (replace this test when updating the default to a later version + than gnu23). */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#if __STDC_VERSION__ == 202311L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-int.c b/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-int.c index a40c3ddcb3108f078a7a0a8d8920b27650b1f6ac..9f75cedd0230eb4770b3dc5f7ae6dc4207788149 100644 --- a/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-int.c +++ b/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-int.c @@ -49,6 +49,7 @@ unsigned int table[16] = { int table_cycle_size = 16; /* Return 0 if 'result' is a valid value to have loaded. */ +__attribute__((noinline)) int verify_result () { int x; @@ -69,6 +70,7 @@ int verify_result () } /* Iterate VALUE through the different valid values. */ +__attribute__((noinline)) void simulate_thread_other_threads () { static int current = 0; @@ -78,11 +80,13 @@ void simulate_thread_other_threads () value = table[current]; } +__attribute__((noinline)) int simulate_thread_step_verify () { return verify_result (); } +__attribute__((noinline)) int simulate_thread_final_verify () { return verify_result (); diff --git a/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-longlong.c b/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-longlong.c index 524b9845b910396f55c29740d1546ce03e543812..6c3b3a3981f894a5d7c5ddbbdc08afc799bc15e1 100644 --- a/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-longlong.c +++ b/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-longlong.c @@ -51,6 +51,7 @@ unsigned long long table[16] = { int table_cycle_size = 16; /* Return 0 if 'result' is a valid value to have loaded. */ +__attribute__((noinline)) int verify_result () { int x; @@ -71,6 +72,7 @@ int verify_result () } /* Iterate VALUE through the different valid values. */ +__attribute__((noinline)) void simulate_thread_other_threads () { static int current = 0; @@ -80,11 +82,13 @@ void simulate_thread_other_threads () value = table[current]; } +__attribute__((noinline)) int simulate_thread_step_verify () { return verify_result (); } +__attribute__((noinline)) int simulate_thread_final_verify () { return verify_result (); diff --git a/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-short.c b/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-short.c index 62690cea5f88280ab3ccf77cfbde68682dfdcae3..53b8c084eb3949af317c3399c644302b3809de18 100644 --- a/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-short.c +++ b/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-short.c @@ -49,6 +49,7 @@ unsigned short table[16] = { int table_cycle_size = 16; /* Return 0 if 'result' is a valid value to have loaded. */ +__attribute__((noinline)) int verify_result () { int x; @@ -69,6 +70,7 @@ int verify_result () } /* Iterate VALUE through the different valid values. */ +__attribute__((noinline)) void simulate_thread_other_threads () { static int current = 0; @@ -78,11 +80,13 @@ void simulate_thread_other_threads () value = table[current]; } +__attribute__((noinline)) int simulate_thread_step_verify () { return verify_result (); } +__attribute__((noinline)) int simulate_thread_final_verify () { return verify_result (); diff --git a/gcc/testsuite/gcc.dg/torture/pr117496-1.c b/gcc/testsuite/gcc.dg/torture/pr117496-1.c index f35d13dfa85daee5125c0dd75ad74baa1b356a6a..d68286ef7721a4bdf209645f6127321750513c72 100644 --- a/gcc/testsuite/gcc.dg/torture/pr117496-1.c +++ b/gcc/testsuite/gcc.dg/torture/pr117496-1.c @@ -1,4 +1,5 @@ /* { dg-do compile } */ +/* { dg-additional-options "-std=gnu17" } */ /* PR tree-optimization/117496 */