aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-10-30 12:17:40 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2017-10-30 12:17:40 +0000
commitc76dc9c32d616eff1e0ae162042f1c0f8ca65fbf (patch)
treeb75365b3cb27dcf745496a2403394a4df80386d6 /libcpp
parentaa650b641022754c1ee6a58130fe2984d06d9657 (diff)
downloadgcc-c76dc9c32d616eff1e0ae162042f1c0f8ca65fbf.zip
gcc-c76dc9c32d616eff1e0ae162042f1c0f8ca65fbf.tar.gz
gcc-c76dc9c32d616eff1e0ae162042f1c0f8ca65fbf.tar.bz2
Add -std=c17, -std=gnu17.
C17, a bug-fix version of the C11 standard with DR resolutions integrated, will soon go to ballot. This patch adds corresponding options -std=c17, -std=gnu17 (new default version, replacing -std=gnu11 as the default), -std=iso9899:2017. As a bug-fix version of the standard, there is no need for flag_isoc17 or any options for compatibility warnings; however, there is a new __STDC_VERSION__ value, so new cpplib languages CLK_GNUC17 and CLK_STDC17 are added to support using that new value with the new options. (If the standard ends up being published in 2018 and being known as C18, option aliases can be added. Note however that -std=iso9899:199409 corresponds to a __STDC_VERSION__ value rather than a publication date.) (There are a couple of DR resolutions needing implementing in GCC, but that's independent of the new options.) (I'd propose to add -std=c2x / -std=gnu2x / -Wc11-c2x-compat for the next major C standard revision once there are actually C2x drafts being issued with new features included.) Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc: * doc/invoke.texi (C Dialect Options): Document -std=c17, -std=iso9899:2017 and -std=gnu17. * doc/standards.texi (C Language): Document C17 support. * doc/cpp.texi (Overview): Mention -std=c17. (Standard Predefined Macros): Document C11 and C17 values of __STDC_VERSION__. Do not refer to C99 support as incomplete. * doc/extend.texi (Inline): Do not list individual options for standards newer than C99. * dwarf2out.c (highest_c_language, gen_compile_unit_die): Handle "GNU C17". * config/rl78/rl78.c (rl78_option_override): Handle "GNU C17" language name. gcc/c-family: * c.opt (std=c17, std=gnu17, std=iso9899:2017): New options. * c-opts.c (set_std_c17): New function. (c_common_init_options): Use gnu17 as default C version. (c_common_handle_option): Handle -std=c17 and -std=gnu17. gcc/testsuite: * gcc.dg/c17-version-1.c, gcc.dg/c17-version-2.c: New tests. libcpp: * include/cpplib.h (enum c_lang): Add CLK_GNUC17 and CLK_STDC17. * init.c (lang_defaults): Add GNUC17 and STDC17 data. (cpp_init_builtins): Handle C17 value of __STDC_VERSION__. From-SVN: r254216
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/include/cpplib.h4
-rw-r--r--libcpp/init.c5
3 files changed, 13 insertions, 2 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index f2c0d4d..785be4f 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-30 Joseph Myers <joseph@codesourcery.com>
+
+ * include/cpplib.h (enum c_lang): Add CLK_GNUC17 and CLK_STDC17.
+ * init.c (lang_defaults): Add GNUC17 and STDC17 data.
+ (cpp_init_builtins): Handle C17 value of __STDC_VERSION__.
+
2017-10-10 Nathan Sidwell <nathan@acm.org>
PR preprocessor/82506
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 804132a..a2dc93d 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -168,8 +168,8 @@ enum cpp_ttype
#undef TK
/* C language kind, used when calling cpp_create_reader. */
-enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11,
- CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11,
+enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, CLK_GNUC17,
+ CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11, CLK_STDC17,
CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11,
CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17,
CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM};
diff --git a/libcpp/init.c b/libcpp/init.c
index 16ff202..ecc81e31 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -98,10 +98,12 @@ static const struct lang_flags lang_defaults[] =
/* GNUC89 */ { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
/* GNUC99 */ { 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0 },
/* GNUC11 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0 },
+ /* GNUC17 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0 },
/* STDC89 */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0 },
/* STDC94 */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0 },
/* STDC99 */ { 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0 },
/* STDC11 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0 },
+ /* STDC17 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0 },
/* GNUCXX */ { 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
/* CXX98 */ { 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0 },
/* GNUCXX11 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0 },
@@ -518,6 +520,9 @@ cpp_init_builtins (cpp_reader *pfile, int hosted)
_cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
else if (CPP_OPTION (pfile, lang) == CLK_STDC94)
_cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
+ else if (CPP_OPTION (pfile, lang) == CLK_STDC17
+ || CPP_OPTION (pfile, lang) == CLK_GNUC17)
+ _cpp_define_builtin (pfile, "__STDC_VERSION__ 201710L");
else if (CPP_OPTION (pfile, lang) == CLK_STDC11
|| CPP_OPTION (pfile, lang) == CLK_GNUC11)
_cpp_define_builtin (pfile, "__STDC_VERSION__ 201112L");