]> gcc.gnu.org Git - gcc.git/commit
c: Add -std=c23, -std=gnu23, -Wc11-c23-compat options [PR107954]
authorJoseph Myers <joseph@codesourcery.com>
Mon, 6 Nov 2023 15:01:22 +0000 (15:01 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Mon, 6 Nov 2023 15:01:22 +0000 (15:01 +0000)
commitfad61bf73b3158157a136bf4d9373fc3d9afe319
tree9f15256a6102bdba4a2cfe594a7f4931c660d2b8
parent9837f62f066db532c9db6df38ccf2653d0c3a960
c: Add -std=c23, -std=gnu23, -Wc11-c23-compat options [PR107954]

At the June WG14 meeting, WG14 decided it preferred to keep C23 as the
informal name for the next revision of the C standard, despite
publication not being before 2024 (publication is due in 2024 whether
or not technical changes at the January meeting result in an FDIS
ballot being needed).  At the Cauldron I raised the question of
whether we should thus now add option names such as -std=c23 to GCC,
and there was support for doing so.

Add -std=c23, making -std=c2x a deprecated alias; also add the alias
-std=iso9899:2024.  Likewise, add -std=gnu23, making -std=gnu2x a
deprecated alias, and add -Wc11-c23-compat, making -Wc11-c2x-compat a
deprecated alias.

Here, I'm generally just adding the new options and making the minimum
changes required to do so, with documentation changed to refer to C23
instead of C2X only where directly associated with documentation of
these options.  It's intended that future changes will update
documentation, diagnostics, comments, variable names, testcase names,
etc. to refer consistently to C23.  When such changes are made, the
new tests c23-opts-3.c, c23-opts-5.c and gnu23-opts-2.c are intended
to keep using the old option names they are specifically testing,
while other tests would start using the c23/gnu23 versions of the
names (as well as the tests themselves being renamed).

Updating option names is independent of updating to the final
__STDC_VERSION__ value.  There, the question is whether we should
update the value now or wait for the remaining significant features to
be implemented first.  (I intend to review Martin's tag compatibility
patches for GCC 14.  I'm not aware of anyone working on #embed - or on
the [[unsequenced]] and [[reproducible]] attributes, though support
for standard attributes is optional.)

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

PR c/107954

gcc/
* doc/cpp.texi (__STDC_VERSION__): Refer to -std=c23 and
-std=gnu23 instead of -std=c2x and -std=gnu2x.
* doc/extend.texi (Attribute Syntax): Refer to C23 and -std=c23
instead of C2x and -std=c2x.
* doc/invoke.texi (-Wc11-c23-compat, -std=c23, -std=gnu23)
(-std=iso9899:2024): Document, with -Wc11-c2x-compat, -std=c2x and
-std=gnu2x as deprecated aliases.  Update descriptions of C23.
* doc/standards.texi (Standards): Describe C23 with C2X as an old
name.

gcc/c-family/
* c.opt (Wc11-c2x-compat): Rename to Wc11-c23-compat and make into
a deprecated alias of Wc11-c23-compat.
(std=c2x): Rename to std=c23 and make into a deprecated alias of
std=c23.
(std=gnu2x): Rename to std=gnu23 and make into a deprecated alias
of std=gnu23.
(std=iso9899:2024): New option.  Alias of std=c23.
* c-lex.cc (interpret_float): Use OPT_Wc11_c23_compat instead of
OPT_Wc11_c2x_compat.
* c-opts.cc (c_common_handle_option): Use OPT_std_c23 instead of
OPT_std_c2x and OPT_std_gnu23 instead of OPT_std_gnu2x.

gcc/c/
* c-errors.cc (pedwarn_c11): Use OPT_Wc11_c23_compat instead of
OPT_Wc11_c2x_compat.
* c-typeck.cc (build_conditional_expr, convert_for_assignment):
Use OPT_Wc11_c23_compat instead of OPT_Wc11_c2x_compat.

gcc/testsuite/
* gcc.dg/c23-opts-1.c, gcc.dg/c23-opts-2.c, gcc.dg/c23-opts-3.c,
gcc.dg/c23-opts-4.c, gcc.dg/c23-opts-5.c, gcc.dg/gnu23-opts-1.c,
gcc.dg/gnu23-opts-2.c: New tests.
16 files changed:
gcc/c-family/c-lex.cc
gcc/c-family/c-opts.cc
gcc/c-family/c.opt
gcc/c/c-errors.cc
gcc/c/c-typeck.cc
gcc/doc/cpp.texi
gcc/doc/extend.texi
gcc/doc/invoke.texi
gcc/doc/standards.texi
gcc/testsuite/gcc.dg/c23-opts-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-opts-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-opts-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-opts-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-opts-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gnu23-opts-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gnu23-opts-2.c [new file with mode: 0644]
This page took 0.077238 seconds and 6 git commands to generate.