summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/c-family/ChangeLog7
-rw-r--r--gcc/c-family/c-opts.c30
-rw-r--r--gcc/c-family/c.opt12
-rw-r--r--gcc/config/rl78/rl78.c1
-rw-r--r--gcc/doc/cpp.texi11
-rw-r--r--gcc/doc/extend.texi4
-rw-r--r--gcc/doc/invoke.texi12
-rw-r--r--gcc/doc/standards.texi8
-rw-r--r--gcc/dwarf2out.c5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/c17-version-1.c9
-rw-r--r--gcc/testsuite/gcc.dg/c17-version-2.c9
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/include/cpplib.h4
-rw-r--r--libcpp/init.c5
16 files changed, 129 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3e38a8ecc6e..0274d9b2f50 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2017-10-30 Joseph Myers <joseph@codesourcery.com>
+
+ * 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.
+
2017-10-30 Maxim Ostapenko <m.ostapenko@samsung.com>
* asan.c (asan_finish_file): Align asan globals array by shadow
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index e9c62e13495..6942d5f8954 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,10 @@
+2017-10-30 Joseph Myers <joseph@codesourcery.com>
+
+ * 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.
+
2017-10-27 Michael Meissner <meissner@linux.vnet.ibm.com>
* c-cppbuiltin.c (mode_has_fma): Add support for PowerPC KFmode.
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 6bd535532d3..32120e636c2 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -115,6 +115,7 @@ static void set_std_cxx2a (int);
static void set_std_c89 (int, int);
static void set_std_c99 (int);
static void set_std_c11 (int);
+static void set_std_c17 (int);
static void check_deps_environment_vars (void);
static void handle_deferred_opts (void);
static void sanitize_cpp_opts (void);
@@ -236,8 +237,8 @@ c_common_init_options (unsigned int decoded_options_count,
if (c_language == clk_c)
{
- /* The default for C is gnu11. */
- set_std_c11 (false /* ISO */);
+ /* The default for C is gnu17. */
+ set_std_c17 (false /* ISO */);
/* If preprocessing assembly language, accept any of the C-family
front end options since the driver may pass them through. */
@@ -675,6 +676,16 @@ c_common_handle_option (size_t scode, const char *arg, int value,
set_std_c11 (false /* ISO */);
break;
+ case OPT_std_c17:
+ if (!preprocessing_asm_p)
+ set_std_c17 (true /* ISO */);
+ break;
+
+ case OPT_std_gnu17:
+ if (!preprocessing_asm_p)
+ set_std_c17 (false /* ISO */);
+ break;
+
case OPT_trigraphs:
cpp_opts->trigraphs = 1;
break;
@@ -1559,6 +1570,21 @@ set_std_c11 (int iso)
lang_hooks.name = "GNU C11";
}
+/* Set the C 17 standard (without GNU extensions if ISO). */
+static void
+set_std_c17 (int iso)
+{
+ cpp_set_lang (parse_in, iso ? CLK_STDC17: CLK_GNUC17);
+ flag_no_asm = iso;
+ flag_no_nonansi_builtin = iso;
+ flag_iso = iso;
+ flag_isoc11 = 1;
+ flag_isoc99 = 1;
+ flag_isoc94 = 1;
+ lang_hooks.name = "GNU C17";
+}
+
+
/* Set the C++ 98 standard (without GNU extensions if ISO). */
static void
set_std_cxx98 (int iso)
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 13d2a59b8a5..dae124ac1c2 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1944,6 +1944,10 @@ std=c1x
C ObjC Alias(std=c11)
Deprecated in favor of -std=c11.
+std=c17
+C ObjC
+Conform to the ISO 2017 C standard.
+
std=c89
C ObjC Alias(std=c90)
Conform to the ISO 1990 C standard.
@@ -2006,6 +2010,10 @@ std=gnu1x
C ObjC Alias(std=gnu11)
Deprecated in favor of -std=gnu11.
+std=gnu17
+C ObjC
+Conform to the ISO 2017 C standard with GNU extensions.
+
std=gnu89
C ObjC Alias(std=gnu90)
Conform to the ISO 1990 C standard with GNU extensions.
@@ -2042,6 +2050,10 @@ std=iso9899:2011
C ObjC Alias(std=c11)
Conform to the ISO 2011 C standard.
+std=iso9899:2017
+C ObjC Alias(std=c17)
+Conform to the ISO 2017 C standard.
+
traditional
Driver
diff --git a/gcc/config/rl78/rl78.c b/gcc/config/rl78/rl78.c
index c835dc0317b..7b381b1f78a 100644
--- a/gcc/config/rl78/rl78.c
+++ b/gcc/config/rl78/rl78.c
@@ -360,6 +360,7 @@ rl78_option_override (void)
if (TARGET_ES0
&& strcmp (lang_hooks.name, "GNU C")
&& strcmp (lang_hooks.name, "GNU C11")
+ && strcmp (lang_hooks.name, "GNU C17")
&& strcmp (lang_hooks.name, "GNU C89")
&& strcmp (lang_hooks.name, "GNU C99")
/* Compiling with -flto results in a language of GNU GIMPLE being used... */
diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index 759532d1273..8cafb6554f8 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -211,8 +211,8 @@ Standard C@. In its default mode, the GNU C preprocessor does not do a
few things required by the standard. These are features which are
rarely, if ever, used, and may cause surprising changes to the meaning
of a program which does not expect them. To get strict ISO Standard C,
-you should use the @option{-std=c90}, @option{-std=c99} or
-@option{-std=c11} options, depending
+you should use the @option{-std=c90}, @option{-std=c99},
+@option{-std=c11} or @option{-std=c17} options, depending
on which version of the standard you want. To get all the mandatory
diagnostics, you must also use @option{-pedantic}. @xref{Invocation}.
@@ -1857,8 +1857,11 @@ implementation, unless GNU CPP is being used with GCC@.
The value @code{199409L} signifies the 1989 C standard as amended in
1994, which is the current default; the value @code{199901L} signifies
-the 1999 revision of the C standard. Support for the 1999 revision is
-not yet complete.
+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).
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/extend.texi b/gcc/doc/extend.texi
index b1b9c29d185..8aa443f87fb 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -7775,8 +7775,8 @@ GCC implements three different semantics of declaring a function
inline. One is available with @option{-std=gnu89} or
@option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
on all inline declarations, another when
-@option{-std=c99}, @option{-std=c11},
-@option{-std=gnu99} or @option{-std=gnu11}
+@option{-std=c99},
+@option{-std=gnu99} or an option for a later C version is used
(without @option{-fgnu89-inline}), and the third
is used when compiling C++.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 8df09020f14..43acbcbbcd7 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1831,6 +1831,13 @@ substantially completely supported, modulo bugs, floating-point issues
Annexes F and G) and the optional Annexes K (Bounds-checking
interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
+@item c17
+@itemx iso9899:2017
+ISO C17, the 2017 revision of the ISO C standard. This standard is
+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 gnu90
@itemx gnu89
GNU dialect of ISO C90 (including some C99 features).
@@ -1841,9 +1848,12 @@ GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
@item gnu11
@itemx gnu1x
-GNU dialect of ISO C11. This is the default for C code.
+GNU dialect of ISO C11.
The name @samp{gnu1x} is deprecated.
+@item gnu17
+GNU dialect of ISO C17. This is the default for C code.
+
@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 d4112b37863..a40899dba85 100644
--- a/gcc/doc/standards.texi
+++ b/gcc/doc/standards.texi
@@ -36,6 +36,8 @@ with some exceptions, and possibly with some extensions.
@cindex C11
@cindex ISO C1X
@cindex C1X
+@cindex ISO C17
+@cindex C17
@cindex Technical Corrigenda
@cindex TC1
@cindex Technical Corrigendum 1
@@ -100,7 +102,11 @@ in 2011 as ISO/IEC 9899:2011. (While in development, drafts of this
standard version were referred to as @dfn{C1X}.)
GCC has substantially complete support
for this standard, enabled with @option{-std=c11} or
-@option{-std=iso9899:2011}.
+@option{-std=iso9899:2011}. A version with corrections integrated is
+known as @dfn{C17} and is supported with @option{-std=c17} or
+@option{-std=iso9899:2017}; the corrections are also applied with
+@option{-std=c11}, and the only difference between the options is the
+value of @code{__STDC_VERSION__}.
By default, GCC provides some extensions to the C language that, on
rare occasions conflict with the C standard. @xref{C
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 54a47d51618..1a15c96f3c5 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -23434,6 +23434,8 @@ highest_c_language (const char *lang1, const char *lang2)
if (strcmp ("GNU C++98", lang1) == 0 || strcmp ("GNU C++98", lang2) == 0)
return "GNU C++98";
+ if (strcmp ("GNU C17", lang1) == 0 || strcmp ("GNU C17", lang2) == 0)
+ return "GNU C17";
if (strcmp ("GNU C11", lang1) == 0 || strcmp ("GNU C11", lang2) == 0)
return "GNU C11";
if (strcmp ("GNU C99", lang1) == 0 || strcmp ("GNU C99", lang2) == 0)
@@ -23510,7 +23512,8 @@ gen_compile_unit_die (const char *filename)
language = DW_LANG_C99;
if (dwarf_version >= 5 /* || !dwarf_strict */)
- if (strcmp (language_string, "GNU C11") == 0)
+ if (strcmp (language_string, "GNU C11") == 0
+ || strcmp (language_string, "GNU C17") == 0)
language = DW_LANG_C11;
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ef3e9ae27f0..6f98a1a7acc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-30 Joseph Myers <joseph@codesourcery.com>
+
+ * gcc.dg/c17-version-1.c, gcc.dg/c17-version-2.c: New tests.
+
2017-10-30 Jakub Jelinek <jakub@redhat.com>
PR middle-end/22141
diff --git a/gcc/testsuite/gcc.dg/c17-version-1.c b/gcc/testsuite/gcc.dg/c17-version-1.c
new file mode 100644
index 00000000000..4e69a6eec11
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c17-version-1.c
@@ -0,0 +1,9 @@
+/* Test __STDC_VERSION__ for C17. Test -std=c17. */
+/* { dg-do compile } */
+/* { dg-options "-std=c17 -pedantic-errors" } */
+
+#if __STDC_VERSION__ == 201710L
+int i;
+#else
+#error "Bad __STDC_VERSION__."
+#endif
diff --git a/gcc/testsuite/gcc.dg/c17-version-2.c b/gcc/testsuite/gcc.dg/c17-version-2.c
new file mode 100644
index 00000000000..3f367204094
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c17-version-2.c
@@ -0,0 +1,9 @@
+/* Test __STDC_VERSION__ for C17. Test -std=iso9899:2017. */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:2017 -pedantic-errors" } */
+
+#if __STDC_VERSION__ == 201710L
+int i;
+#else
+#error "Bad __STDC_VERSION__."
+#endif
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index f2c0d4d63fd..785be4f94ac 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 804132a44da..a2dc93da87e 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 16ff202c8cf..ecc81e3138a 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");