From 9f936c861383dc69e0053e34315d5d0262a19e8f Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 18 Oct 2018 00:58:54 +0100 Subject: Add -std=c2x, -std=gnu2x, -Wc11-c2x-compat, C2X _Static_assert support. Now new features are starting to be added to a C2X draft (in the C2x branch of the C standard git repository, no public WG14 document yet), it's time to add -std=c2x and associated options to GCC for use in enabling C2X features. This patch adds the expected set of options: -std=c2x, -std=gnu2x, -Wc11-c2x-compat. A first C2X feature is added (the only one so far in the repository that's obviously relevant to GCC): support (as in C++) for the string constant to be omitted in _Static_assert. This feature is duly also supported as an extension in earlier standard modes (diagnosed with -pedantic, unless -Wno-c11-c2x-compat is given, or with -Wc11-c2x-compat even in C2X mode). Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/ * doc/cpp.texi (__STDC_VERSION__): Document C2X handling. * doc/invoke.texi (-std=c2x, -std=gnu2x): Document new options. * doc/standards.texi (C Language): Document C2X. * dwarf2out.c (highest_c_language), config/rl78/rl78.c (rl78_option_override): Handle "GNU C2X" language name. gcc/c/ * c-errors.c (pedwarn_c11): New function. * c-parser.c (disable_extension_diagnostics): Save warn_c11_c2x_compat and set it to 0. (restore_extension_diagnostics): Restore warn_c11_c2x_compat. (c_parser_static_assert_declaration_no_semi): Handle _Static_assert without string constant. * c-tree.h (pedwarn_c11): New prototype. gcc/c-family/ * c-common.c (flag_isoc2x): New variable. * c-common.h (clk_c): Update comment to reference C2X. (flag_isoc99, flag_isoc11): Update comments to reference future standard versions in general. (flag_isoc2x): Declare. * c-opts.c (set_std_c2x): New function. (c_common_handle_option): Handle -std=c2x and -std=gnu2x. (set_std_c89, set_std_c99, set_std_c11, set_std_c17): Set flag_isoc2x to 0. * c.opt (Wc11-c2x-compat, std=c2x, std=gnu2x): New options. gcc/testsuite/ * gcc.dg/c11-static-assert-7.c, gcc.dg/c11-static-assert-8.c, gcc.dg/c11-static-assert-9.c, gcc.dg/c2x-static-assert-1.c, gcc.dg/c2x-static-assert-2.c, gcc.dg/c99-static-assert-2.c, gcc.dg/gnu2x-static-assert-1.c: New tests. * gcc.dg/missing-symbol-3.c: Update expected fix-it text. libcpp/ * include/cpplib.h (enum c_lang): Add CLK_GNUC2X and CLK_STDC2X. * init.c (lang_defaults): Add GNUC2X and STDC2X entries. (cpp_init_builtins): Define __STDC_VERSION__ to 202000L for C2X. From-SVN: r265251 --- gcc/doc/cpp.texi | 3 ++- gcc/doc/invoke.texi | 9 +++++++++ gcc/doc/standards.texi | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'gcc/doc') diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index 5345574..cb5d5bd 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -1887,7 +1887,8 @@ the 1999 revision of the C standard; the value @code{201112L} 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). +defects). An unspecified value larger than @code{201710L} is used for +the experimental @option{-std=c2x} and @option{-std=gnu2x} 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 7b08076..bf8bcfb 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1933,6 +1933,10 @@ same as C11 except for corrections of defects (all of which are also applied with @option{-std=c11}) and a new value of @code{__STDC_VERSION__}, and so is supported to the same extent as C11. +@item c2x +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). @@ -1950,6 +1954,11 @@ The name @samp{gnu1x} is deprecated. @itemx gnu18 GNU dialect of ISO C17. This is the default for C code. +@item gnu2x +The next version of the ISO C standard, still under development, plus +GNU extensions. The support for this version is experimental and +incomplete. + @item c++98 @itemx c++03 The 1998 ISO C++ standard plus the 2003 technical corrigendum and some diff --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi index bd9ff6b..26350cc 100644 --- a/gcc/doc/standards.texi +++ b/gcc/doc/standards.texi @@ -38,6 +38,8 @@ with some exceptions, and possibly with some extensions. @cindex C1X @cindex ISO C17 @cindex C17 +@cindex ISO C2X +@cindex C2X @cindex Technical Corrigenda @cindex TC1 @cindex Technical Corrigendum 1 @@ -109,6 +111,10 @@ 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{C2X}, is under +development; experimental and incomplete support for this is enabled +with @option{-std=c2x}. + 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}. -- cgit v1.1