From patchwork Mon Nov 6 15:03:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 162044 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2718025vqu; Mon, 6 Nov 2023 07:04:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxT8ioNRxRY0/WhkuEbD72eKFd15VT3y8Q+5mm7e5oayN3j8tuhNAYq3h97l60wtOc1Ex3 X-Received: by 2002:a05:6358:918b:b0:16b:631e:5021 with SMTP id j11-20020a056358918b00b0016b631e5021mr3786643rwa.7.1699283048440; Mon, 06 Nov 2023 07:04:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699283048; cv=pass; d=google.com; s=arc-20160816; b=tOagwcf74YaEG3VcQKyXvLzm2Wz4lLYbRBoqwSUwIzeyYkaC/TdAtT8k6w8OIsyMHI /H7PDjI3f0SsRttlSlGdnLTeImB1SvIwlKzJUc6tLWsxO7eD87eVllUREJwk+lIXpaIH 2+wLR7tm7EPgWu2hCWlUGkQwSUV9lPE7FsK8lPR6+02u+KH1wUjDeQoUbLCcYzmbwB/n CLrtUC+zPxU1nJC0pQqU9/knMuysUAJ9lofiS4kkLXBcHWuwUY1fFeFFPOE+HyXggfvR 8LUgneDxjDEqhm/QwxkBO0NlrzC1qY8S1e8Bw5VJKYF/ttxFIF8Qvurnp9KAgkIQmmm1 XaVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:subject :to:from:date:ironport-sdr:arc-filter:dmarc-filter:delivered-to; bh=y8nEKha0RnKWgPnJjWBQ7fFUpipbmIZs5WxIY7JAw0U=; fh=gk9A5O7Gbglvz1MjrRQ4hZ2i3c68kYkpOZJg1emXh+g=; b=KdunooprmegEQAXsvE+ZUUpJtxasvjHNIOaNzeq9zj6FV0EHIxfgD8lZoVueG4arVp asHalfKwA2AwKG16if60yJ92Big/bUyFHdfcRh8oGFQ4qzJjk+Nr2aM5sEhMGN78OhpZ u+vl5avxptyLYHcwTVRvNy6CEkRI/NxBYLfIBGIBmomrQHnlBpwWgLFV0VYW/IRPxtDQ NnxFQVjmUe61n9eoWZL+dpwG8oEOa1pxjz7XQbdn5J5qG8LfD57nayfA7Csfit6XPFpt 7wE/0HE1YWi5UNQJQeZc0SV8/ElIJr53JkmDqVA5VfxgMJyyi+Z47eY8nU9DC4HQoKvr uQwQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m18-20020ab061d2000000b0079db5009579si830900uan.46.2023.11.06.07.04.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 07:04:08 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 362A6386187C for ; Mon, 6 Nov 2023 15:04:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id ADF2D385AC09 for ; Mon, 6 Nov 2023 15:03:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ADF2D385AC09 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ADF2D385AC09 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.141.98 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699283014; cv=none; b=Pf2ry9r3BNSqKMEZre6xU/GzRo9yC+V/lfYIBTXCXR6HPvLnPx4qaEsZMN6gzXLIGEtDfdLEnSjc8YnLKlJCeQD/L1MiZ1zFpjVm8NQPZfDT/LQUBIID16dQWZHjoO3dGN5Mwxa2FuNCP9rswyN2lq3goIoTucyHP+Cc147A1Og= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699283014; c=relaxed/simple; bh=bJQO7vPI9w3TnBuK2cf7VquHt0Xwl+/WORTHc8AM61Y=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=graR6qdJlfvxzg8ArKudP2oEXrnlqEVJvNRBLg8c28xnif79SufEa27XhmsPp26NjzkEm2YJG2o3XetyJiaZoBLo7Ptu4VdunvBa1xy4XDSGwg7Q/8QqJbkTtpV4SdCqNSlaX4Fc6KFTjUnofRyYY2BnPoyQJvbuKqUzObk7aSA= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: 4WWT66FjTfakwqi7KC3Efg== X-CSE-MsgGUID: yIGT7DxlTgKGy41LlOQTJQ== X-IronPort-AV: E=Sophos;i="6.03,281,1694764800"; d="scan'208";a="24685675" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 06 Nov 2023 07:03:30 -0800 IronPort-SDR: TvhGVRJ/kLutEKiTy1AEGMe5Vh4dUMtFIeYRf3QaHtHIY15L2fzth1Ga8sm2DGjTZ1hDkZH15h asOOS11iyGJwcIwBPh7HaETEwt27ZFR5d8EJwZGF2u+mSetJgvx7a/gH2sP9xcS7/I3DFNiK8t a715kL9zS7d+b+DsDDGicYzo6cVQYmDeWlceS8GWW8Q8hSMNakecHD1DM4+MV/DE3UqoOP6pqk guM69TpcptQC5GcuHGF4z3keMfLZKzhx1pSTp0rRkm4PBnI7g02LlU8zGAbcOafMI9Hess90Oz oqo= Date: Mon, 6 Nov 2023 15:03:25 +0000 From: Joseph Myers To: Subject: [committed] c: Add -std=c23, -std=gnu23, -Wc11-c23-compat options [PR107954] Message-ID: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3109.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781827421538793719 X-GMAIL-MSGID: 1781827421538793719 At the June WG14 meeting, WG14 decided it preferred to keep C23 as the informal name for the next revision of the C standard, despite publication not being before 2024 (publication is due in 2024 whether or not technical changes at the January meeting result in an FDIS ballot being needed). At the Cauldron I raised the question of whether we should thus now add option names such as -std=c23 to GCC, and there was support for doing so. Add -std=c23, making -std=c2x a deprecated alias; also add the alias -std=iso9899:2024. Likewise, add -std=gnu23, making -std=gnu2x a deprecated alias, and add -Wc11-c23-compat, making -Wc11-c2x-compat a deprecated alias. Here, I'm generally just adding the new options and making the minimum changes required to do so, with documentation changed to refer to C23 instead of C2X only where directly associated with documentation of these options. It's intended that future changes will update documentation, diagnostics, comments, variable names, testcase names, etc. to refer consistently to C23. When such changes are made, the new tests c23-opts-3.c, c23-opts-5.c and gnu23-opts-2.c are intended to keep using the old option names they are specifically testing, while other tests would start using the c23/gnu23 versions of the names (as well as the tests themselves being renamed). Updating option names is independent of updating to the final __STDC_VERSION__ value. There, the question is whether we should update the value now or wait for the remaining significant features to be implemented first. (I intend to review Martin's tag compatibility patches for GCC 14. I'm not aware of anyone working on #embed - or on the [[unsequenced]] and [[reproducible]] attributes, though support for standard attributes is optional.) Bootstrapped with no regressions for x86_64-pc-linux-gnu. PR c/107954 gcc/ * doc/cpp.texi (__STDC_VERSION__): Refer to -std=c23 and -std=gnu23 instead of -std=c2x and -std=gnu2x. * doc/extend.texi (Attribute Syntax): Refer to C23 and -std=c23 instead of C2x and -std=c2x. * doc/invoke.texi (-Wc11-c23-compat, -std=c23, -std=gnu23) (-std=iso9899:2024): Document, with -Wc11-c2x-compat, -std=c2x and -std=gnu2x as deprecated aliases. Update descriptions of C23. * doc/standards.texi (Standards): Describe C23 with C2X as an old name. gcc/c-family/ * c.opt (Wc11-c2x-compat): Rename to Wc11-c23-compat and make into a deprecated alias of Wc11-c23-compat. (std=c2x): Rename to std=c23 and make into a deprecated alias of std=c23. (std=gnu2x): Rename to std=gnu23 and make into a deprecated alias of std=gnu23. (std=iso9899:2024): New option. Alias of std=c23. * c-lex.cc (interpret_float): Use OPT_Wc11_c23_compat instead of OPT_Wc11_c2x_compat. * c-opts.cc (c_common_handle_option): Use OPT_std_c23 instead of OPT_std_c2x and OPT_std_gnu23 instead of OPT_std_gnu2x. gcc/c/ * c-errors.cc (pedwarn_c11): Use OPT_Wc11_c23_compat instead of OPT_Wc11_c2x_compat. * c-typeck.cc (build_conditional_expr, convert_for_assignment): Use OPT_Wc11_c23_compat instead of OPT_Wc11_c2x_compat. gcc/testsuite/ * gcc.dg/c23-opts-1.c, gcc.dg/c23-opts-2.c, gcc.dg/c23-opts-3.c, gcc.dg/c23-opts-4.c, gcc.dg/c23-opts-5.c, gcc.dg/gnu23-opts-1.c, gcc.dg/gnu23-opts-2.c: New tests. diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc index 5e457b78cdd..a05632295cf 100644 --- a/gcc/c-family/c-lex.cc +++ b/gcc/c-family/c-lex.cc @@ -1190,11 +1190,11 @@ interpret_float (const cpp_token *token, unsigned int flags, if (warn_c11_c2x_compat > 0) { if (pedantic && !flag_isoc2x) - pedwarn (input_location, OPT_Wc11_c2x_compat, + pedwarn (input_location, OPT_Wc11_c23_compat, "non-standard suffix on floating constant " "before C2X"); else - warning (OPT_Wc11_c2x_compat, + warning (OPT_Wc11_c23_compat, "non-standard suffix on floating constant " "before C2X"); } diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index e9f7e6d424d..6b64821cbf0 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -732,12 +732,12 @@ c_common_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, set_std_c17 (false /* ISO */); break; - case OPT_std_c2x: + case OPT_std_c23: if (!preprocessing_asm_p) set_std_c2x (true /* ISO */); break; - case OPT_std_gnu2x: + case OPT_std_gnu23: if (!preprocessing_asm_p) set_std_c2x (false /* ISO */); break; diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 29d3d789a49..359f071e632 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -433,9 +433,13 @@ Wbuiltin-macro-redefined C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) CppReason(CPP_W_BUILTIN_MACRO_REDEFINED) Var(cpp_warn_builtin_macro_redefined) Init(1) Warning Warn when a built-in preprocessor macro is undefined or redefined. -Wc11-c2x-compat +Wc11-c23-compat C ObjC CPP(cpp_warn_c11_c2x_compat) CppReason(CPP_W_C11_C2X_COMPAT) Var(warn_c11_c2x_compat) Init(-1) Warning -Warn about features not present in ISO C11, but present in ISO C2X. +Warn about features not present in ISO C11, but present in ISO C23. + +Wc11-c2x-compat +C ObjC Alias(Wc11-c23-compat) +Deprecated in favor of -Wc11-c23-compat. Wc90-c99-compat C ObjC CPP(cpp_warn_c90_c99_compat) CppReason(CPP_W_C90_C99_COMPAT) Var(warn_c90_c99_compat) Init(-1) Warning @@ -2463,9 +2467,13 @@ std=c18 C ObjC Alias(std=c17) Conform to the ISO 2017 C standard (published in 2018). -std=c2x +std=c23 C ObjC -Conform to the ISO 202X C standard draft (experimental and incomplete support). +Conform to the ISO 2023 C standard draft (expected to be published in 2024) (experimental and incomplete support). + +std=c2x +C ObjC Alias(std=c23) +Deprecated in favor of -std=c23. std=c89 C ObjC Alias(std=c90) @@ -2557,9 +2565,13 @@ std=gnu18 C ObjC Alias(std=gnu17) Conform to the ISO 2017 C standard (published in 2018) with GNU extensions. -std=gnu2x +std=gnu23 C ObjC -Conform to the ISO 202X C standard draft with GNU extensions (experimental and incomplete support). +Conform to the ISO 2023 C standard draft (expected to be published in 2024) with GNU extensions (experimental and incomplete support). + +std=gnu2x +C ObjC Alias(std=gnu23) +Deprecated in favor of -std=gnu23. std=gnu89 C ObjC Alias(std=gnu90) @@ -2605,6 +2617,10 @@ std=iso9899:2018 C ObjC Alias(std=c17) Conform to the ISO 2017 C standard (published in 2018). +std=iso9899:2024 +C ObjC Alias(std=c23) +Conform to the ISO 2023 C standard draft (expected to be published in 2024) (experimental and incomplete support). + stdlib= Driver C++ ObjC++ Common Condition(ENABLE_STDLIB_OPTION) Var(flag_stdlib_kind) Joined Enum(stdlib_kind) RejectNegative Init(1) -stdlib=[libstdc++|libc++] The standard library to be used for C++ headers diff --git a/gcc/c/c-errors.cc b/gcc/c/c-errors.cc index 01c521e5536..87bb13c6b25 100644 --- a/gcc/c/c-errors.cc +++ b/gcc/c/c-errors.cc @@ -47,7 +47,7 @@ pedwarn_c11 (location_t location, int opt, const char *gmsgid, ...) diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, (pedantic && !flag_isoc2x) ? DK_PEDWARN : DK_WARNING); - diagnostic.option_index = OPT_Wc11_c2x_compat; + diagnostic.option_index = OPT_Wc11_c23_compat; warned = diagnostic_report_diagnostic (global_dc, &diagnostic); } /* -Wno-c11-c2x-compat suppresses even the pedwarns. */ diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index bdd57aae3ff..dd39cec9204 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -5545,7 +5545,7 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, "pointer to array loses qualifier " "in conditional expression"); else if (warn_c11_c2x_compat > 0) - warning_at (colon_loc, OPT_Wc11_c2x_compat, + warning_at (colon_loc, OPT_Wc11_c23_compat, "pointer to array loses qualifier " "in conditional expression in ISO C before C2X"); } @@ -7603,7 +7603,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, "pointer target type"), TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl)); else if (warn_quals_ped) - pedwarn_c11 (location, OPT_Wc11_c2x_compat, + pedwarn_c11 (location, OPT_Wc11_c23_compat, "array with qualifier on the element is not qualified before C2X"); /* If this is not a case of ignoring a mismatch in signedness, diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index 3f492b33470..705e587ace6 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -1887,7 +1887,7 @@ 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). An unspecified value larger than @code{201710L} is used for -the experimental @option{-std=c2x} and @option{-std=gnu2x} modes. +the experimental @option{-std=c23} and @option{-std=gnu23} 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/extend.texi b/gcc/doc/extend.texi index fa7402813e7..6575c2be483 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -9443,8 +9443,8 @@ default language dialect for both C and C++. More specifically, this syntax was first introduced in the C++11 language standard (@pxref{Standards}), and is supported by GCC in C++ code with @option{-std=c++11} or @option{-std=gnu++11} or later. It is also -part of the C2x language standard and is supported when compiling C -code with @option{-std=c2x} or @option{-std=gnu17} or later. +part of the C23 language standard and is supported when compiling C +code with @option{-std=c23} or @option{-std=gnu17} or later. When using GNU-specific attributes in the standard syntax, you must prefix their names with @samp{gnu::}, such as @code{gnu::section}. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 6e776a0faa1..80bb1efac40 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -337,7 +337,7 @@ Objective-C and Objective-C++ Dialects}. -Wbool-compare -Wbool-operation -Wno-builtin-declaration-mismatch -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat --Wc11-c2x-compat +-Wc11-c23-compat -Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat -Wc++20-compat -Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions @@ -2432,9 +2432,12 @@ 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 c23 +@itemx c2x +@itemx iso9899:2024 +ISO C23, the 2023 revision of the ISO C standard (expected to be +published in 2024). The support for this version is experimental and +incomplete. The name @samp{c2x} is deprecated. @item gnu90 @itemx gnu89 @@ -2453,10 +2456,11 @@ The name @samp{gnu1x} is deprecated. @itemx gnu18 GNU dialect of ISO C17. This is the default for C code. -@item gnu2x +@item gnu23 +@itemx gnu2x The next version of the ISO C standard, still under development, plus GNU extensions. The support for this version is experimental and -incomplete. +incomplete. The name @samp{gnu2x} is deprecated. @item c++98 @itemx c++03 @@ -2566,10 +2570,10 @@ this switch. You may want to use the @option{-fno-gnu-keywords} flag instead, which disables @code{typeof} but not @code{asm} and @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this switch only affects the @code{asm} and @code{typeof} keywords, -since @code{inline} is a standard keyword in ISO C99. In C2X mode -(@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects +since @code{inline} is a standard keyword in ISO C99. In C23 mode +(@option{-std=c23} or @option{-std=gnu23}), this switch only affects the @code{asm} keyword, since @code{typeof} is a standard keyword in -ISO C2X. +ISO C23. @opindex fno-builtin @opindex fbuiltin @@ -8998,17 +9002,19 @@ For instance, warn about use of anonymous structures and unions, and so on. This option is independent of the standards mode. Warnings are disabled in the expression that follows @code{__extension__}. -@opindex Wc11-c2x-compat -@opindex Wno-c11-c2x-compat -@item -Wc11-c2x-compat @r{(C and Objective-C only)} -Warn about features not present in ISO C11, but present in ISO C2X. +@opindex Wc11-c23-compat +@opindex Wno-c11-c23-compat +@item -Wc11-c23-compat @r{(C and Objective-C only)} +@itemx -Wc11-c2x-compat @r{(C and Objective-C only)} +Warn about features not present in ISO C11, but present in ISO C23. For instance, warn about omitting the string in @code{_Static_assert}, use of @samp{[[]]} syntax for attributes, use of decimal floating-point types, and so on. This option is independent of the standards mode. Warnings are disabled in the expression that follows -@code{__extension__}. +@code{__extension__}. The name @option{-Wc11-c2x-compat} is +deprecated. -When not compiling in C2X mode, these warnings are upgraded to errors +When not compiling in C23 mode, these warnings are upgraded to errors by @option{-pedantic-errors}. @opindex Wc++-compat diff --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi index 2bcb664eb6b..4eb43f14f90 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 C23 +@cindex C23 @cindex ISO C2X @cindex C2X @cindex Technical Corrigenda @@ -111,9 +113,11 @@ 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}. +A further version of the C standard, known as @dfn{C23}, is under +development and expected to be published in 2024 as ISO/IEC 9899:2024. +(While in development, drafts of this standard version were referred +to as @dfn{C2X}.) Experimental and incomplete support for this is +enabled with @option{-std=c23} or @option{-std=iso9899:2024}. 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/testsuite/gcc.dg/c23-opts-1.c b/gcc/testsuite/gcc.dg/c23-opts-1.c new file mode 100644 index 00000000000..a72c6c6e7af --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-opts-1.c @@ -0,0 +1,5 @@ +/* Test -std=c23. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23" } */ + +auto p = nullptr; diff --git a/gcc/testsuite/gcc.dg/c23-opts-2.c b/gcc/testsuite/gcc.dg/c23-opts-2.c new file mode 100644 index 00000000000..47081a84745 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-opts-2.c @@ -0,0 +1,5 @@ +/* Test -std=iso9899:2024. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:2024" } */ + +auto p = nullptr; diff --git a/gcc/testsuite/gcc.dg/c23-opts-3.c b/gcc/testsuite/gcc.dg/c23-opts-3.c new file mode 100644 index 00000000000..37b8bce1a09 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-opts-3.c @@ -0,0 +1,5 @@ +/* Test the deprecated option -std=c2x. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x" } */ + +auto p = nullptr; diff --git a/gcc/testsuite/gcc.dg/c23-opts-4.c b/gcc/testsuite/gcc.dg/c23-opts-4.c new file mode 100644 index 00000000000..a501bc838d7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-opts-4.c @@ -0,0 +1,5 @@ +/* Test -Wc11-c23-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -Wc11-c23-compat" } */ + +void *p = nullptr; /* { dg-warning "nullptr" } */ diff --git a/gcc/testsuite/gcc.dg/c23-opts-5.c b/gcc/testsuite/gcc.dg/c23-opts-5.c new file mode 100644 index 00000000000..39e486deb96 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-opts-5.c @@ -0,0 +1,5 @@ +/* Test the deprecated option -Wc11-c2x-compat. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -Wc11-c2x-compat" } */ + +void *p = nullptr; /* { dg-warning "nullptr" } */ diff --git a/gcc/testsuite/gcc.dg/gnu23-opts-1.c b/gcc/testsuite/gcc.dg/gnu23-opts-1.c new file mode 100644 index 00000000000..e5de935bf02 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu23-opts-1.c @@ -0,0 +1,5 @@ +/* Test -std=gnu23. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu23" } */ + +auto p = nullptr; diff --git a/gcc/testsuite/gcc.dg/gnu23-opts-2.c b/gcc/testsuite/gcc.dg/gnu23-opts-2.c new file mode 100644 index 00000000000..a3980d92581 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu23-opts-2.c @@ -0,0 +1,5 @@ +/* Test the deprecated option -std=gnu2x. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2x" } */ + +auto p = nullptr;