+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
+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.
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);
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. */
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;
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)
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.
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.
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
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... */
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}.
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@.
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++.
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).
@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
@cindex C11
@cindex ISO C1X
@cindex C1X
+@cindex ISO C17
+@cindex C17
@cindex Technical Corrigenda
@cindex TC1
@cindex Technical Corrigendum 1
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
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)
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;
}
}
+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
--- /dev/null
+/* 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
--- /dev/null
+/* 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
+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
#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};
/* 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 },
_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");