aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorJoseph Myers <josmyers@redhat.com>2024-06-11 23:00:04 +0000
committerJoseph Myers <josmyers@redhat.com>2024-06-11 23:00:04 +0000
commit0cf68222d2df3af7fefad28a82fcd51d8b40a192 (patch)
tree701b30abd2d7acb11f081f6f9de304ef119189cf /gcc/doc
parent6bc26cceb243c6f359f65a1afa5515f911f3327d (diff)
downloadgcc-0cf68222d2df3af7fefad28a82fcd51d8b40a192.zip
gcc-0cf68222d2df3af7fefad28a82fcd51d8b40a192.tar.gz
gcc-0cf68222d2df3af7fefad28a82fcd51d8b40a192.tar.bz2
c: Add -std=c2y, -std=gnu2y, -Wc23-c2y-compat, C2Y _Generic with type operand
The first new C2Y feature, _Generic where the controlling operand is a type name rather than an expression (as defined in N3260), was voted into C2Y today. (In particular, this form of _Generic allows distinguishing qualified and unqualified versions of a type.) This feature also includes allowing the generic associations to specify incomplete and function types. Add this feature to GCC, along with the -std=c2y, -std=gnu2y and -Wc23-c2y-compat options to control when and how it is diagnosed. As usual, the feature is allowed by default in older standards modes, subject to diagnosis with -pedantic, -pedantic-errors or -Wc23-c2y-compat. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/ * doc/cpp.texi (__STDC_VERSION__): Document C2Y handling. * doc/invoke.texi (-Wc23-c2y-compat, -std=c2y, -std=gnu2y): Document options. (-std=gnu23): Update documentation. * doc/standards.texi (C Language): Document C2Y. Update C23 description. * config/rl78/rl78.cc (rl78_option_override): Handle "GNU C2Y" language name. * dwarf2out.cc (highest_c_language, gen_compile_unit_die): Likewise. gcc/c-family/ * c-common.cc (flag_isoc2y): New. (flag_isoc99, flag_isoc11, flag_isoc23): Update comments. * c-common.h (flag_isoc2y): New. (clk_c, flag_isoc23): Update comments. * c-opts.cc (set_std_c2y): New. (c_common_handle_option): Handle OPT_std_c2y and OPT_std_gnu2y. (set_std_c89, set_std_c99, set_std_c11, set_std_c17, set_std_c23): Set flag_isoc2y. (set_std_c23): Update comment. * c.opt (Wc23-c2y-compat, std=c2y, std=gnu2y): New. * c.opt.urls: Regenerate. gcc/c/ * c-errors.cc (pedwarn_c23): New. * c-parser.cc (disable_extension_diagnostics) (restore_extension_diagnostics): Save and restore warn_c23_c2y_compat. (c_parser_generic_selection): Handle type name as controlling operand. Allow incomplete and function types subject to pedwarn_c23 calls. * c-tree.h (pedwarn_c23): New. gcc/testsuite/ * gcc.dg/c23-generic-1.c, gcc.dg/c23-generic-2.c, gcc.dg/c23-generic-3.c, gcc.dg/c23-generic-4.c, gcc.dg/c2y-generic-1.c, gcc.dg/c2y-generic-2.c, gcc.dg/c2y-generic-3.c, gcc.dg/gnu2y-generic-1.c: New tests. * gcc.dg/c23-tag-6.c: Use -pedantic-errors. libcpp/ * include/cpplib.h (CLK_GNUC2Y, CLK_STDC2Y): New. * init.cc (lang_defaults): Add GNUC2Y and STDC2Y entries. (cpp_init_builtins): Define __STDC_VERSION__ to 202500L for GNUC2Y and STDC2Y.
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/cpp.texi4
-rw-r--r--gcc/doc/invoke.texi23
-rw-r--r--gcc/doc/standards.texi8
3 files changed, 32 insertions, 3 deletions
diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index 3f38ca3..a99c8df 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -1887,7 +1887,9 @@ signifies the 2011 revision of the C standard; the value
@code{201710L} signifies the 2017 revision of the C standard (which is
otherwise identical to the 2011 version apart from correction of
defects). The value @code{202311L} is used for the experimental
-@option{-std=c23} and @option{-std=gnu23} modes.
+@option{-std=c23} and @option{-std=gnu23} modes. An unspecified value
+larger than @code{202311L} is used for the experimental
+@option{-std=c2y} and @option{-std=gnu2y} modes.
This macro is not defined if the @option{-traditional-cpp} option is
used, nor when compiling C++ or Objective-C@.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index a0b3756..26e6a34 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -340,7 +340,7 @@ Objective-C and Objective-C++ Dialects}.
-Wbool-compare -Wbool-operation
-Wno-builtin-declaration-mismatch
-Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat
--Wc11-c23-compat
+-Wc11-c23-compat -Wc23-c2y-compat
-Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat
-Wc++20-compat
-Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions
@@ -2472,6 +2472,10 @@ ISO C23, the 2023 revision of the ISO C standard (expected to be
published in 2024). The support for this version is experimental and
incomplete. The name @samp{c2x} is deprecated.
+@item c2y
+The next version of the ISO C standard, still under development. The
+support for this version is experimental and incomplete.
+
@item gnu90
@itemx gnu89
GNU dialect of ISO C90 (including some C99 features).
@@ -2491,6 +2495,10 @@ GNU dialect of ISO C17. This is the default for C code.
@item gnu23
@itemx gnu2x
+GNU dialect of ISO C23. The support for this version is experimental
+and incomplete. The name @samp{gnu2x} is deprecated.
+
+@item gnu2y
The next version of the ISO C standard, still under development, plus
GNU extensions. The support for this version is experimental and
incomplete. The name @samp{gnu2x} is deprecated.
@@ -9326,6 +9334,19 @@ deprecated.
When not compiling in C23 mode, these warnings are upgraded to errors
by @option{-pedantic-errors}.
+@opindex Wc23-c2y-compat
+@opindex Wno-c23-c2y-compat
+@item -Wc23-c2y-compat @r{(C and Objective-C only)}
+@itemx -Wc23-c2y-compat @r{(C and Objective-C only)}
+Warn about features not present in ISO C23, but present in ISO C2Y.
+For instance, warn about @code{_Generic} selecting with a type name
+instead of an expression. This option is independent of the standards
+mode. Warnings are disabled in the expression that follows
+@code{__extension__}.
+
+When not compiling in C2Y mode, these warnings are upgraded to errors
+by @option{-pedantic-errors}.
+
@opindex Wc++-compat
@opindex Wno-c++-compat
@item -Wc++-compat @r{(C and Objective-C only)}
diff --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi
index 586835b..484fbb1 100644
--- a/gcc/doc/standards.texi
+++ b/gcc/doc/standards.texi
@@ -42,6 +42,8 @@ with some exceptions, and possibly with some extensions.
@cindex C23
@cindex ISO C2X
@cindex C2X
+@cindex ISO C2Y
+@cindex C2Y
@cindex Technical Corrigenda
@cindex TC1
@cindex Technical Corrigendum 1
@@ -113,12 +115,16 @@ known as @dfn{C17} and is supported with @option{-std=c17} or
@option{-std=c11}, and the only difference between the options is the
value of @code{__STDC_VERSION__}.
-A further version of the C standard, known as @dfn{C23}, is under
+A fifth version of the C standard, known as @dfn{C23}, is under
development and expected to be published in 2024 as ISO/IEC 9899:2024.
(While in development, drafts of this standard version were referred
to as @dfn{C2X}.) Experimental and incomplete support for this is
enabled with @option{-std=c23} or @option{-std=iso9899:2024}.
+A further version of the C standard, known as @dfn{C2Y}, is under
+development; experimental and incomplete support for this is enabled
+with @option{-std=c2y}.
+
By default, GCC provides some extensions to the C language that, on
rare occasions conflict with the C standard. @xref{C
Extensions,,Extensions to the C Language Family}.