From 48b0b19630a19eaab06efd305387b930f94fc5d3 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 20 Dec 2011 20:44:13 +0000 Subject: [PATCH] gcc: * c-decl.c (diagnose_mismatched_decls, grokdeclarator, grokfield) (finish_struct): Refer to C11 in comments. Use flag_isoc11. * c-parser.c (c_parser_static_assert_declaration) (c_parser_static_assert_declaration_no_semi, c_parser_declspecs) (c_parser_alignas_specifier, c_parser_alignof_expression): Refer to C11 in comments. Use flag_isoc11. * c-typeck.c (comptypes_check_different_types): Refer to C11 in comment. * doc/cpp.texi (Overview): Refer to -std=c11 instead of -std=c1x. * doc/cppopts.texi (-std=c11, -std=gnu11): Document in preference to -std=c1x and -std=gnu1x. * doc/extend.texi (Inline, Alternate Keywords, Other Builtins) (__builtin_complex, Unnamed Fields): Refer to -std=c11 and C11 instead of -std=c1x and C1X. * doc/invoke.texi (-std=c11, -std=iso9899:2011): Document in preference to -std=c1x. (-std=gnu11): Document in preference to -std=gnu1x. * doc/standards.texi: Document C11 instead of C1X. Document C11 as actual standard. Document headers required from freestanding C11 implementations. * ginclude/float.h, ginclude/stddef.h: Test __STDC_VERSION__ >= 201112L for C11. Update comments to refer to C11. gcc/c-family: * c-common.c (flag_isoc99): Update comment to refer to C11. (flag_isoc1x): Change to flag_isoc11. * c-common.h (flag_isoc99): Update comment to refer to C11. (flag_isoc1x): Change to flag_isoc11. * c-cppbuiltin.c (cpp_atomic_builtins): Change comment to refer to C11. * c-opts.c (set_std_c1x): Change to set_std_c11. (c_common_handle_option): Handle OPT_std_c11 and OPT_std_gnu11. Call set_std_c11. (set_std_c89, set_std_c99, set_std_c11): Use flag_isoc11. (set_std_c1): Use CLK_STDC11 and CLK_GNUC11. * c.opt (std=c1x): Change to std=c11. Document as non-draft standard. (std=c1x, std=iso9899:2011): Add as aliases of std=c11. (std=gnu1x): Change to std=gnu11. Refer to non-draft standard. (std=gnu1x): Make alias of std=gnu11. gcc/testsuite: * gcc.dg/c11-version-1.c, gcc.dg/c11-version-2.c, gcc.dg/c94-version-1.c, gcc.dg/c99-version-1.c, gcc.dg/gnu11-version-1.c: New tests. libcpp: * include/cpplib.h (CLK_GNUC1X): Change to CLK_GNUC11. (CLK_STDC1X): Change to CLK_STDC11. * init.c (lang_defaults): Update comments. (cpp_init_builtins): Update language tests. Use 201112L for C11 __STDC_VERSION__. From-SVN: r182551 --- gcc/ChangeLog | 25 +++++++++++++++++++++++++ gcc/c-decl.c | 12 ++++++------ gcc/c-family/ChangeLog | 19 +++++++++++++++++++ gcc/c-family/c-common.c | 6 +++--- gcc/c-family/c-common.h | 8 ++++---- gcc/c-family/c-cppbuiltin.c | 2 +- gcc/c-family/c-opts.c | 22 +++++++++++----------- gcc/c-family/c.opt | 20 ++++++++++++++++---- gcc/c-parser.c | 20 ++++++++++---------- gcc/c-typeck.c | 2 +- gcc/doc/cpp.texi | 2 +- gcc/doc/cppopts.texi | 13 ++++++++----- gcc/doc/extend.texi | 12 ++++++------ gcc/doc/invoke.texi | 17 +++++++++-------- gcc/doc/standards.texi | 23 +++++++++++++++-------- gcc/ginclude/float.h | 7 ++++--- gcc/ginclude/stddef.h | 4 ++-- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.dg/c11-version-1.c | 9 +++++++++ gcc/testsuite/gcc.dg/c11-version-2.c | 9 +++++++++ gcc/testsuite/gcc.dg/c94-version-1.c | 9 +++++++++ gcc/testsuite/gcc.dg/c99-version-1.c | 9 +++++++++ gcc/testsuite/gcc.dg/gnu11-version-1.c | 9 +++++++++ libcpp/ChangeLog | 8 ++++++++ libcpp/include/cpplib.h | 4 ++-- libcpp/init.c | 10 +++++----- 26 files changed, 207 insertions(+), 80 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/c11-version-1.c create mode 100644 gcc/testsuite/gcc.dg/c11-version-2.c create mode 100644 gcc/testsuite/gcc.dg/c94-version-1.c create mode 100644 gcc/testsuite/gcc.dg/c99-version-1.c create mode 100644 gcc/testsuite/gcc.dg/gnu11-version-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5135a67c541..ad53a035ba9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,28 @@ +2011-12-20 Joseph Myers + + * c-decl.c (diagnose_mismatched_decls, grokdeclarator, grokfield) + (finish_struct): Refer to C11 in comments. Use flag_isoc11. + * c-parser.c (c_parser_static_assert_declaration) + (c_parser_static_assert_declaration_no_semi, c_parser_declspecs) + (c_parser_alignas_specifier, c_parser_alignof_expression): Refer + to C11 in comments. Use flag_isoc11. + * c-typeck.c (comptypes_check_different_types): Refer to C11 in + comment. + * doc/cpp.texi (Overview): Refer to -std=c11 instead of -std=c1x. + * doc/cppopts.texi (-std=c11, -std=gnu11): Document in preference + to -std=c1x and -std=gnu1x. + * doc/extend.texi (Inline, Alternate Keywords, Other Builtins) + (__builtin_complex, Unnamed Fields): Refer to -std=c11 and C11 + instead of -std=c1x and C1X. + * doc/invoke.texi (-std=c11, -std=iso9899:2011): Document in + preference to -std=c1x. + (-std=gnu11): Document in preference to -std=gnu1x. + * doc/standards.texi: Document C11 instead of C1X. Document C11 + as actual standard. Document headers required from freestanding + C11 implementations. + * ginclude/float.h, ginclude/stddef.h: Test __STDC_VERSION__ >= + 201112L for C11. Update comments to refer to C11. + 2011-12-20 Andreas Schwab * configure: Regenerate. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 1cdbf2fe6a8..96e9c7d1753 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1786,7 +1786,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, /* Redeclaration of a type is a constraint violation (6.7.2.3p1), but silently ignore the redeclaration if either is in a system header. (Conflicting redeclarations were handled above.) This - is allowed for C1X if the types are the same, not just + is allowed for C11 if the types are the same, not just compatible. */ if (TREE_CODE (newdecl) == TYPE_DECL) { @@ -1815,7 +1815,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, newdecl); locate_old_decl (olddecl); } - else if (pedantic && !flag_isoc1x) + else if (pedantic && !flag_isoc11) { pedwarn (input_location, OPT_pedantic, "redefinition of typedef %q+D", newdecl); @@ -6077,7 +6077,7 @@ grokdeclarator (const struct c_declarator *declarator, DECL_DECLARED_INLINE_P (decl) = 1; if (declspecs->noreturn_p) { - if (!flag_isoc1x) + if (!flag_isoc11) { if (flag_isoc99) pedwarn (loc, OPT_pedantic, @@ -6761,7 +6761,7 @@ grokfield (location_t loc, If this is something of the form "foo;" and foo is a TYPE_DECL, then If foo names a structure or union without a tag, then this - is an anonymous struct (this is permitted by C1X). + is an anonymous struct (this is permitted by C11). If MS or Plan 9 extensions are enabled and foo names a structure, then again this is an anonymous struct. Otherwise this is an error. @@ -6792,7 +6792,7 @@ grokfield (location_t loc, pedwarn (loc, 0, "declaration does not declare anything"); return NULL_TREE; } - if (!flag_isoc1x) + if (!flag_isoc11) { if (flag_isoc99) pedwarn (loc, OPT_pedantic, @@ -7072,7 +7072,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, { if (DECL_NAME (x) != 0) break; - if (flag_isoc1x + if (flag_isoc11 && (TREE_CODE (TREE_TYPE (x)) == RECORD_TYPE || TREE_CODE (TREE_TYPE (x)) == UNION_TYPE)) break; diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 2b8f3257861..b076e7602f3 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,22 @@ +2011-12-20 Joseph Myers + + * c-common.c (flag_isoc99): Update comment to refer to C11. + (flag_isoc1x): Change to flag_isoc11. + * c-common.h (flag_isoc99): Update comment to refer to C11. + (flag_isoc1x): Change to flag_isoc11. + * c-cppbuiltin.c (cpp_atomic_builtins): Change comment to refer to + C11. + * c-opts.c (set_std_c1x): Change to set_std_c11. + (c_common_handle_option): Handle OPT_std_c11 and OPT_std_gnu11. + Call set_std_c11. + (set_std_c89, set_std_c99, set_std_c11): Use flag_isoc11. + (set_std_c1): Use CLK_STDC11 and CLK_GNUC11. + * c.opt (std=c1x): Change to std=c11. Document as non-draft + standard. + (std=c1x, std=iso9899:2011): Add as aliases of std=c11. + (std=gnu1x): Change to std=gnu11. Refer to non-draft standard. + (std=gnu1x): Make alias of std=gnu11. + 2011-12-19 Jason Merrill PR c++/51228 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 0562f2624f3..6f88760c947 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -216,13 +216,13 @@ int flag_cond_mismatch; int flag_isoc94; -/* Nonzero means use the ISO C99 (or C1X) dialect of C. */ +/* Nonzero means use the ISO C99 (or C11) dialect of C. */ int flag_isoc99; -/* Nonzero means use the ISO C1X dialect of C. */ +/* Nonzero means use the ISO C11 dialect of C. */ -int flag_isoc1x; +int flag_isoc11; /* Nonzero means that we have builtin functions, and main is an int. */ diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 103c5816ac4..835b13bbce8 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -106,7 +106,7 @@ enum rid RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128, RID_FRACT, RID_ACCUM, - /* C1X */ + /* C11 */ RID_ALIGNAS, /* This means to warn that this is a C++ keyword, and then treat it @@ -607,13 +607,13 @@ extern int flag_cond_mismatch; extern int flag_isoc94; -/* Nonzero means use the ISO C99 (or C1X) dialect of C. */ +/* Nonzero means use the ISO C99 (or C11) dialect of C. */ extern int flag_isoc99; -/* Nonzero means use the ISO C1X dialect of C. */ +/* Nonzero means use the ISO C11 dialect of C. */ -extern int flag_isoc1x; +extern int flag_isoc11; /* Nonzero means that we have builtin functions, and main is an int. */ diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 8d0d4af9c92..7e7b9c15876 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -646,7 +646,7 @@ cpp_atomic_builtins (cpp_reader *pfile) have_swap[16] = true; } - /* Tell the source code about various types. These map to the C++11 and C1x + /* Tell the source code about various types. These map to the C++11 and C11 macros where 2 indicates lock-free always, and 1 indicates sometimes lock free. */ #define SIZEOF_NODE(T) (tree_low_cst (TYPE_SIZE_UNIT (T), 1)) diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index a08b0e80a56..3a4d8a87f62 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -113,7 +113,7 @@ static void set_std_cxx98 (int); static void set_std_cxx11 (int); static void set_std_c89 (int, int); static void set_std_c99 (int); -static void set_std_c1x (int); +static void set_std_c11 (int); static void check_deps_environment_vars (void); static void handle_deferred_opts (void); static void sanitize_cpp_opts (void); @@ -799,14 +799,14 @@ c_common_handle_option (size_t scode, const char *arg, int value, set_std_c99 (false /* ISO */); break; - case OPT_std_c1x: + case OPT_std_c11: if (!preprocessing_asm_p) - set_std_c1x (true /* ISO */); + set_std_c11 (true /* ISO */); break; - case OPT_std_gnu1x: + case OPT_std_gnu11: if (!preprocessing_asm_p) - set_std_c1x (false /* ISO */); + set_std_c11 (false /* ISO */); break; case OPT_trigraphs: @@ -1465,7 +1465,7 @@ set_std_c89 (int c94, int iso) flag_no_nonansi_builtin = iso; flag_isoc94 = c94; flag_isoc99 = 0; - flag_isoc1x = 0; + flag_isoc11 = 0; } /* Set the C 99 standard (without GNU extensions if ISO). */ @@ -1476,20 +1476,20 @@ set_std_c99 (int iso) flag_no_asm = iso; flag_no_nonansi_builtin = iso; flag_iso = iso; - flag_isoc1x = 0; + flag_isoc11 = 0; flag_isoc99 = 1; flag_isoc94 = 1; } -/* Set the C 1X standard draft (without GNU extensions if ISO). */ +/* Set the C 11 standard (without GNU extensions if ISO). */ static void -set_std_c1x (int iso) +set_std_c11 (int iso) { - cpp_set_lang (parse_in, iso ? CLK_STDC1X: CLK_GNUC1X); + cpp_set_lang (parse_in, iso ? CLK_STDC11: CLK_GNUC11); flag_no_asm = iso; flag_no_nonansi_builtin = iso; flag_iso = iso; - flag_isoc1x = 1; + flag_isoc11 = 1; flag_isoc99 = 1; flag_isoc94 = 1; } diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 7694794e0c6..42c9a0dfc66 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1191,9 +1191,13 @@ std=c++0x C++ ObjC++ Alias(std=c++11) Deprecated in favor of -std=c++11 -std=c1x +std=c11 C ObjC -Conform to the ISO 201X C standard draft (experimental and incomplete support) +Conform to the ISO 2011 C standard (experimental and incomplete support) + +std=c1x +C ObjC Alias(std=c11) +Deprecated in favor of -std=c11 std=c89 C ObjC Alias(std=c90) @@ -1229,9 +1233,13 @@ std=gnu++0x C++ ObjC++ Alias(std=gnu++11) Deprecated in favor of -std=gnu++11 -std=gnu1x +std=gnu11 C ObjC -Conform to the ISO 201X C standard draft with GNU extensions (experimental and incomplete support) +Conform to the ISO 2011 C standard with GNU extensions (experimental and incomplete support) + +std=gnu1x +C ObjC Alias(std=gnu11) +Deprecated in favor of -std=gnu11 std=gnu89 C ObjC Alias(std=gnu90) @@ -1265,6 +1273,10 @@ std=iso9899:199x C ObjC Alias(std=c99) Deprecated in favor of -std=iso9899:1999 +std=iso9899:2011 +C ObjC Alias(std=c11) +Conform to the ISO 2011 C standard (experimental and incomplete support) + traditional Driver diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 0a268a691f5..867ab4183ad 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -1796,7 +1796,7 @@ c_parser_asm_definition (c_parser *parser) c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>"); } -/* Parse a static assertion (C1X N1425 6.7.10). +/* Parse a static assertion (C11 6.7.10). static_assert-declaration: static_assert-declaration-no-semi ; @@ -1811,7 +1811,7 @@ c_parser_static_assert_declaration (c_parser *parser) c_parser_skip_to_end_of_block_or_statement (parser); } -/* Parse a static assertion (C1X N1425 6.7.10), without the trailing +/* Parse a static assertion (C11 6.7.10), without the trailing semicolon. static_assert-declaration-no-semi: @@ -1827,7 +1827,7 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser) gcc_assert (c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT)); assert_loc = c_parser_peek_token (parser)->location; - if (!flag_isoc1x) + if (!flag_isoc11) { if (flag_isoc99) pedwarn (assert_loc, OPT_pedantic, @@ -1902,7 +1902,7 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser) Function specifiers (inline) are from C99, and are currently handled as storage class specifiers, as is __thread. Alignment - specifiers are from C1X. + specifiers are from C11. C90 6.5.1, C99 6.7.1: storage-class-specifier: @@ -1917,7 +1917,7 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser) inline _Noreturn - (_Noreturn is new in C1X.) + (_Noreturn is new in C11.) C90 6.5.2, C99 6.7.2: type-specifier: @@ -2768,7 +2768,7 @@ c_parser_typeof_specifier (c_parser *parser) /* Parse an alignment-specifier. - C1X 6.7.5: + C11 6.7.5: alignment-specifier: _Alignas ( type-name ) @@ -2782,7 +2782,7 @@ c_parser_alignas_specifier (c_parser * parser) location_t loc = c_parser_peek_token (parser)->location; gcc_assert (c_parser_next_token_is_keyword (parser, RID_ALIGNAS)); c_parser_consume_token (parser); - if (!flag_isoc1x) + if (!flag_isoc11) { if (flag_isoc99) pedwarn (loc, OPT_pedantic, @@ -5841,7 +5841,7 @@ c_parser_cast_expression (c_parser *parser, struct c_expr *after) __alignof__ ( type-name ) && identifier - (C1X permits _Alignof with type names only.) + (C11 permits _Alignof with type names only.) unary-operator: one of __extension__ __real__ __imag__ @@ -6038,9 +6038,9 @@ c_parser_alignof_expression (c_parser *parser) tree alignof_spelling = c_parser_peek_token (parser)->value; gcc_assert (c_parser_next_token_is_keyword (parser, RID_ALIGNOF)); /* A diagnostic is not required for the use of this identifier in - the implementation namespace; only diagnose it for the C1X + the implementation namespace; only diagnose it for the C11 spelling because of existing code using the other spellings. */ - if (!flag_isoc1x + if (!flag_isoc11 && strcmp (IDENTIFIER_POINTER (alignof_spelling), "_Alignof") == 0) { if (flag_isoc99) diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 4a134b0e524..b696e5e38be 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1014,7 +1014,7 @@ comptypes_check_different_types (tree type1, tree type2, compatible integer type, then this sets *ENUM_AND_INT_P to true; *ENUM_AND_INT_P is never set to false. If DIFFERENT_TYPES_P is not NULL, and the types are compatible but different enough not to be - permitted in C1X typedef redeclarations, then this sets + permitted in C11 typedef redeclarations, then this sets *DIFFERENT_TYPES_P to true; *DIFFERENT_TYPES_P is never set to false, but may or may not be set if the types are incompatible. This differs from comptypes, in that we don't free the seen diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index 821d81687ef..230d32bdfc0 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -216,7 +216,7 @@ 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=c1x} options, depending +@option{-std=c11} options, depending on which version of the standard you want. To get all the mandatory diagnostics, you must also use @option{-pedantic}. @xref{Invocation}. diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi index 6c70a0a9cd0..205d8708833 100644 --- a/gcc/doc/cppopts.texi +++ b/gcc/doc/cppopts.texi @@ -392,8 +392,11 @@ The 1990 C standard, as amended in 1994. The revised ISO C standard, published in December 1999. Before publication, this was known as C9X@. -@item c1x -The next version of the ISO C standard, still under development. +@item iso9899:2011 +@itemx c11 +@itemx c1x +The revised ISO C standard, published in December 2011. Before +publication, this was known as C1X@. @item gnu90 @itemx gnu89 @@ -403,9 +406,9 @@ The 1990 C standard plus GNU extensions. This is the default. @itemx gnu9x The 1999 C standard plus GNU extensions. -@item gnu1x -The next version of the ISO C standard, still under development, plus -GNU extensions. +@item gnu11 +@itemx gnu1x +The 2011 C standard plus GNU extensions. @item c++98 The 1998 ISO C++ standard plus amendments. diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 7f39a61fdb2..6c904c10030 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -5298,8 +5298,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=c1x}, -@option{-std=gnu99} or @option{-std=gnu1x} +@option{-std=c99}, @option{-std=c11}, +@option{-std=gnu99} or @option{-std=gnu11} (without @option{-fgnu89-inline}), and the third is used when compiling C++. @@ -6313,7 +6313,7 @@ a general-purpose header file that should be usable by all programs, including ISO C programs. The keywords @code{asm}, @code{typeof} and @code{inline} are not available in programs compiled with @option{-ansi} or @option{-std} (although @code{inline} can be used in a -program compiled with @option{-std=c99} or @option{-std=c1x}). The +program compiled with @option{-std=c99} or @option{-std=c11}). The ISO C99 keyword @code{restrict} is only available when @option{-std=gnu99} (which will eventually be the default) or @option{-std=c99} (or the equivalent @@ -7623,7 +7623,7 @@ be emitted. @opindex ansi @opindex std Outside strict ISO C mode (@option{-ansi}, @option{-std=c90}, -@option{-std=c99} or @option{-std=c1x}), the functions +@option{-std=c99} or @option{-std=c11}), the functions @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero}, @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml}, @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll}, @@ -7843,7 +7843,7 @@ future revisions. @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag}) The built-in function @code{__builtin_complex} is provided for use in -implementing the ISO C1X macros @code{CMPLXF}, @code{CMPLX} and +implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and @code{CMPLXL}. @var{real} and @var{imag} must have the same type, a real binary floating-point type, and the result has the corresponding complex type with real and imaginary parts @var{real} and @var{imag}. @@ -14123,7 +14123,7 @@ versions earlier than 4.4. @cindex @code{struct} @cindex @code{union} -As permitted by ISO C1X and for compatibility with other compilers, +As permitted by ISO C11 and for compatibility with other compilers, GCC allows you to define a structure or union that contains, as fields, structures and unions without names. For example: diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d0d32434137..36c37e081ee 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1557,11 +1557,12 @@ ISO C99. Note that this standard is not yet fully supported; see @w{@uref{http://gcc.gnu.org/c99status.html}} for more information. The names @samp{c9x} and @samp{iso9899:199x} are deprecated. -@item c1x -ISO C1X, the draft of the next revision of the ISO C standard. -Support is limited and experimental and features enabled by this -option may be changed or removed if changed in or removed from the -standard draft. +@item c11 +@itemx c1x +@itemx iso9899:2011 +ISO C11, the 2011 revision of the ISO C standard. +Support is incomplete and experimental. The name @samp{c1x} is +deprecated. @item gnu90 @itemx gnu89 @@ -1573,10 +1574,10 @@ is the default for C code. GNU dialect of ISO C99. When ISO C99 is fully implemented in GCC, this will become the default. The name @samp{gnu9x} is deprecated. +@item gnu11 @item gnu1x -GNU dialect of ISO C1X. Support is limited and experimental and -features enabled by this option may be changed or removed if changed -in or removed from the standard draft. +GNU dialect of ISO C11. Support is incomplete and experimental. The +name @samp{gnu1x} is deprecated. @item c++98 The 1998 ISO C++ standard plus amendments. Same as @option{-ansi} for diff --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi index 90ddd4769d6..4e288c64c2f 100644 --- a/gcc/doc/standards.texi +++ b/gcc/doc/standards.texi @@ -33,6 +33,8 @@ with some exceptions, and possibly with some extensions. @cindex C99 @cindex ISO C9X @cindex C9X +@cindex ISO C11 +@cindex C11 @cindex ISO C1X @cindex C1X @cindex Technical Corrigenda @@ -95,9 +97,11 @@ Errors in the 1999 ISO C standard were corrected in three Technical Corrigenda published in 2001, 2004 and 2007. GCC does not support the uncorrected version. -A fourth version of the C standard, known as @dfn{C1X}, is under -development; GCC has limited preliminary support for parts of this -standard, enabled with @option{-std=c1x}. +A fourth version of the C standard, known as @dfn{C11}, was published +in 2011 as ISO/IEC 9899:2011. GCC has limited incomplete support for +parts of this standard, enabled with @option{-std=c11} or +@option{-std=iso9899:2011}. (While in development, drafts of this +standard version were referred to as @dfn{C1X}.) By default, GCC provides some extensions to the C language that on rare occasions conflict with the C standard. @xref{C @@ -106,12 +110,14 @@ Extensions,,Extensions to the C Language Family}. Use of the they conflict with the C standard version selected. You may also select an extended version of the C language explicitly with @option{-std=gnu90} (for C90 with GNU extensions), @option{-std=gnu99} -(for C99 with GNU extensions) or @option{-std=gnu1x} (for C1X with GNU +(for C99 with GNU extensions) or @option{-std=gnu11} (for C11 with GNU extensions). The default, if no C language dialect options are given, is @option{-std=gnu90}; this will change to -@option{-std=gnu99} in some future release when the C99 support is +@option{-std=gnu99} or @option{-std=gnu11} in some future release when +the C99 or C11 support is complete. Some features that are part of the C99 standard are -accepted as extensions in C90 mode. +accepted as extensions in C90 mode, and some features that are part of +the C11 standard are accepted as extensions in C90 and C99 modes. The ISO C standard defines (in clause 4) two classes of conforming implementation. A @dfn{conforming hosted implementation} supports the @@ -119,8 +125,9 @@ whole standard including all the library facilities; a @dfn{conforming freestanding implementation} is only required to provide certain library facilities: those in @code{}, @code{}, @code{}, and @code{}; since AMD1, also those in -@code{}; and in C99, also those in @code{} and -@code{}. In addition, complex types, added in C99, are not +@code{}; since C99, also those in @code{} and +@code{}; and since C11, also those in @code{} +and @code{}. In addition, complex types, added in C99, are not required for freestanding implementations. The standard also defines two environments for programs, a @dfn{freestanding environment}, required of all implementations and which may not have library diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h index b78cc0ca6af..2954cc4896a 100644 --- a/gcc/ginclude/float.h +++ b/gcc/ginclude/float.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2002, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2007, 2008, 2009, 2010, 2011 + Free Software Foundation, Inc. This file is part of GCC. @@ -157,7 +158,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif /* C99 */ -#if defined (__STDC_VERSION__) && __STDC_VERSION__ > 199901L +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L /* Versions of DECIMAL_DIG for each floating-point type. */ #undef FLT_DECIMAL_DIG #undef DBL_DECIMAL_DIG @@ -194,7 +195,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define LDBL_TRUE_MIN __LDBL_MIN__ #endif -#endif /* C1X */ +#endif /* C11 */ #ifdef __STDC_WANT_DEC_FP__ /* Draft Technical Report 24732, extension for decimal floating-point diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h index 1cc3cb4e75a..a78a7703387 100644 --- a/gcc/ginclude/stddef.h +++ b/gcc/ginclude/stddef.h @@ -412,7 +412,7 @@ typedef __WINT_TYPE__ wint_t; /* Offset of member MEMBER in a struct of type TYPE. */ #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) -#if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 199901L) \ +#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \ || (defined(__cplusplus) && __cplusplus >= 201103L) #ifndef _GCC_MAX_ALIGN_T #define _GCC_MAX_ALIGN_T @@ -424,7 +424,7 @@ typedef struct { long double __max_align_ld __attribute__((__aligned__(__alignof__(long double)))); } max_align_t; #endif -#endif /* C1X or C++11. */ +#endif /* C11 or C++11. */ #endif /* _STDDEF_H was defined this time */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8cb5093cb64..1d329e24df0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-12-20 Joseph Myers + + * gcc.dg/c11-version-1.c, gcc.dg/c11-version-2.c, + gcc.dg/c94-version-1.c, gcc.dg/c99-version-1.c, + gcc.dg/gnu11-version-1.c: New tests. + 2011-12-20 Bernd Schmidt PR middle-end/51200 diff --git a/gcc/testsuite/gcc.dg/c11-version-1.c b/gcc/testsuite/gcc.dg/c11-version-1.c new file mode 100644 index 00000000000..9ab7936d1ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C11. Test -std=c11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 201112L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/gcc/testsuite/gcc.dg/c11-version-2.c b/gcc/testsuite/gcc.dg/c11-version-2.c new file mode 100644 index 00000000000..3ac2305f77d --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-version-2.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C11. Test -std=iso9899:2011. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:2011 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 201112L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/gcc/testsuite/gcc.dg/c94-version-1.c b/gcc/testsuite/gcc.dg/c94-version-1.c new file mode 100644 index 00000000000..7437dda9054 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c94-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C94. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:199409 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 199409L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/gcc/testsuite/gcc.dg/c99-version-1.c b/gcc/testsuite/gcc.dg/c99-version-1.c new file mode 100644 index 00000000000..b99d54c7e16 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c99-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C99. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 199901L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/gcc/testsuite/gcc.dg/gnu11-version-1.c b/gcc/testsuite/gcc.dg/gnu11-version-1.c new file mode 100644 index 00000000000..56efbd43bdc --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu11-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C11 with GNU extensions. Test -std=gnu11. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 201112L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index a24f6add72c..261b8a52067 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,11 @@ +2011-12-20 Joseph Myers + + * include/cpplib.h (CLK_GNUC1X): Change to CLK_GNUC11. + (CLK_STDC1X): Change to CLK_STDC11. + * init.c (lang_defaults): Update comments. + (cpp_init_builtins): Update language tests. Use 201112L for C11 + __STDC_VERSION__. + 2011-12-20 Andreas Schwab * configure: Regenerate. diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 518fe945ebb..bf59d016231 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -165,8 +165,8 @@ enum cpp_ttype #undef TK /* C language kind, used when calling cpp_create_reader. */ -enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC1X, - CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC1X, +enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, + CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11, CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11, CLK_ASM}; /* Payload of a NUMBER, STRING, CHAR or COMMENT token. */ diff --git a/libcpp/init.c b/libcpp/init.c index ff006b11502..5fa82ca9c3e 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -87,11 +87,11 @@ static const struct lang_flags lang_defaults[] = { /* c99 c++ xnum xid std // digr ulit rlit user_literals */ /* GNUC89 */ { 0, 0, 1, 0, 0, 1, 1, 0, 0, 0 }, /* GNUC99 */ { 1, 0, 1, 0, 0, 1, 1, 1, 1, 0 }, - /* GNUC1X */ { 1, 0, 1, 0, 0, 1, 1, 1, 1, 0 }, + /* GNUC11 */ { 1, 0, 1, 0, 0, 1, 1, 1, 1, 0 }, /* STDC89 */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }, /* STDC94 */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 }, /* STDC99 */ { 1, 0, 1, 0, 1, 1, 1, 0, 0, 0 }, - /* STDC1X */ { 1, 0, 1, 0, 1, 1, 1, 1, 0, 0 }, + /* STDC11 */ { 1, 0, 1, 0, 1, 1, 1, 1, 0, 0 }, /* GNUCXX */ { 0, 1, 1, 0, 0, 1, 1, 0, 0, 0 }, /* CXX98 */ { 0, 1, 1, 0, 1, 1, 1, 0, 0, 0 }, /* GNUCXX11 */ { 1, 1, 1, 0, 0, 1, 1, 1, 1, 1 }, @@ -474,9 +474,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_STDC1X - || CPP_OPTION (pfile, lang) == CLK_GNUC1X) - _cpp_define_builtin (pfile, "__STDC_VERSION__ 201000L"); + else if (CPP_OPTION (pfile, lang) == CLK_STDC11 + || CPP_OPTION (pfile, lang) == CLK_GNUC11) + _cpp_define_builtin (pfile, "__STDC_VERSION__ 201112L"); else if (CPP_OPTION (pfile, c99)) _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");