From patchwork Wed Jul 13 19:29:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp416746eik; Wed, 13 Jul 2022 12:30:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s7AtLV0OU3PdzYb9sG2O6MbZq3HRqaxJMAzSN8aln/FCqkovvTozdTYxrqWXMLBkdIaY/5 X-Received: by 2002:a05:6402:1909:b0:43a:64bb:9f27 with SMTP id e9-20020a056402190900b0043a64bb9f27mr7210296edz.24.1657740606819; Wed, 13 Jul 2022 12:30:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657740606; cv=none; d=google.com; s=arc-20160816; b=bKfsg4tKNTS+xaEKo/LtJMrdzCrdtAZP2oumx/n+vM6HF86BlwpYLNsaoZ0mkBeQBI Lv7pVHoP7vWhuJTPOmkfWcKrRLjkDo9lu0gytWZ7StxULq95jwH9lzBGojelr9IT0oAb kGCswvcuhNeLhvzmEvFV7qJrrB0A5dWsm0cDBvRy4R0msQVcDSDIPUyhNpBvbAuCXU6F z5OBvOMJnE132ggr5ILihG4TX/0iFwLTH9OCR2zol2hJm9nHoTRI64oB1X4eMKzEbWI7 TzS8XTFNgW0RGUMhJ29xfOJG8uUXtvL4Pc0asc4DrTwXKRr6vvnvDCXQ1PG72EC2N6Gm V4Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :content-language:user-agent:mime-version:date:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=NeMQuxORQtfgtBdVSs1+GMfFGKcZBXzgfhdwEeN+0BY=; b=h/LrKdmM9xJkFJoXH9tUJeI8vWl7q98JYdljR7pQNp/lOq+c5pMCm3FL/lv8DiAXl4 8+aJlXuZXmL+llVkgemixDeUJFTJ8z1wXPurUdknMuklqaiemtVlZ0x5MzHNybntxzjD pIVVgd66dF3I6SBrM3bwAPTPm5XgFl7+bcrYrha8p7zx84Jh8HsUC/Y4cX1U4YnPsDjf 3YywcEmX5QMepii+ojy5qrvHk7SX42uUXdp4zl8QO46Al5JvUbZx1Yj57C/BEzyh0N2j lH6nZU4AtLk93GCqhFjkVvViQu7ofCqY2TwwgSUxsMFfu+j82YD2MGA8yOzJyGBK83P7 w7Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xSA6gay8; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id dn7-20020a17090794c700b0072cd463e0d0si2055701ejc.587.2022.07.13.12.30.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 12:30:06 -0700 (PDT) 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; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xSA6gay8; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 965D43885512 for ; Wed, 13 Jul 2022 19:29:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 965D43885512 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657740593; bh=NeMQuxORQtfgtBdVSs1+GMfFGKcZBXzgfhdwEeN+0BY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xSA6gay8CZi1A9bif81wMtHOobpLqes/ZMzCGVxMB1Zi2zrJNNbakbprBvcCe5nR2 Q+EV4kGuGuuL9vAcBE0vwOZC2Y7Ah1PYJ8XMplzxv0Jxx7cK1pfMZGYnDDu3pnuxPN ig5p6P0hBbQF4vLLFBTA0sMT8qTz6xBBsuxTWgaQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id C8F213857347 for ; Wed, 13 Jul 2022 19:29:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C8F213857347 Received: by mail-pj1-x1036.google.com with SMTP id b8so12098359pjo.5 for ; Wed, 13 Jul 2022 12:29:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :content-language:to:from:subject; bh=NeMQuxORQtfgtBdVSs1+GMfFGKcZBXzgfhdwEeN+0BY=; b=4UHivFfLT3Dfmmq2DIyCE31EQ+L+VY5xF1uhLvm3yNVvePLgp5ItFyKOTUzIIrC8sP FNIsRm48FtrSRMv0TnDrcuh7kY85f35yzhF7SwtUfYrCAL3Z4uL3MQZtFcSxz9xGx9li Yvqi5vS+Ll7cLen6yMHOtvH2hse+T1vS8NxUey6f9fxPpc8lORhVqZ92LPnzoM2nUaHk L8H1SG2IwdM9TwAN+3unMJ7VLJBmbG/X4+jDdylqwkYJYzcbP0dq6W+xrastmNIp9apL gl33FkDYKk/nPt59aMwmqixG2WmAq5LzOFphM+HMDzCY3iZVYmOTQWlojnFimglQZpEB HRwg== X-Gm-Message-State: AJIora/Vonc1NRfFhaTrfXqLjrjsZfC2qiW/LopSD4NtAQJEz167vOJF 5QNCDmfxOn/9ayVp6WbuLZqLRxiAhUA= X-Received: by 2002:a17:902:6b07:b0:16b:f220:92fb with SMTP id o7-20020a1709026b0700b0016bf22092fbmr5010722plk.96.1657740548552; Wed, 13 Jul 2022 12:29:08 -0700 (PDT) Received: from ?IPV6:2620:10d:c085:21e1::149c? ([2620:10d:c090:400::5:6389]) by smtp.googlemail.com with ESMTPSA id q8-20020a170902eb8800b0016a7d9e6548sm9069486plg.262.2022.07.13.12.29.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Jul 2022 12:29:07 -0700 (PDT) Message-ID: <045690d0-9a3a-13c9-61d8-6e2c54d53fc7@acm.org> Date: Wed, 13 Jul 2022 15:29:04 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: GCC Patches , Jason Merrill Subject: C++: add -std={c,gnu}++{current,future} X-Spam-Status: No, score=-3038.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Nathan Sidwell via Gcc-patches From: Nathan Sidwell Reply-To: Nathan Sidwell Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1738267014285957591?= X-GMAIL-MSGID: =?utf-8?q?1738267014285957591?= Inspired by a user question. Jason, thoughts? Since C++ is such a moving target, Microsoft have /std:c++latest (AFAICT clang does not), to select the currently implemented version of the working paper. But the use of 'std:latest' is somewhat ambiguous -- the current std is C++20 -- that's the latest std, the next std will more than likely but not necessarily be C++23. So this adds: -std=c++current -- the current std (c++20) -std=c++future -- the working paper (c++2b) also adds gnu++current and gnu++future to select the gnu-extended variants. nathan From 9671f4d5e7efa130280b6d50fb4e9e8492d5b587 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 13 Jul 2022 12:11:40 -0700 Subject: [PATCH] C++: add -std={c,gnu}++{current,future} Since C++ is such a moving target, Microsoft have /std:c++latest (AFAICT clang does not), to select the currently implemented version of the working paper. But the use of 'std:latest' is somewhat ambiguous -- the current std is C++20 -- that's the latest std, the next std will more than likely but not necessarily be C++23. So this adds: -std=c++current -- the current std (c++20) -std=c++future -- the working paper (c++2b) also adds gnu++current and gnu++future to select the gnu-extended variants. gcc/ * doc/invoke.texi (-std=): Document new c++ current & future options. gcc/c-family/ * c.opt (-std={c,gnu}++{current,future}: New alias options. gcc/testsuite/ * g++.dg/gnu-current.C: New. * g++.dg/gnu-future.C: New. * g++.dg/std-current.C: New. * g++.dg/std-future.C: New. --- gcc/c-family/c.opt | 16 ++++++++++++++++ gcc/doc/invoke.texi | 23 +++++++++++++++++++++++ gcc/testsuite/g++.dg/gnu-current.C | 7 +++++++ gcc/testsuite/g++.dg/gnu-future.C | 7 +++++++ gcc/testsuite/g++.dg/std-current.C | 11 +++++++++++ gcc/testsuite/g++.dg/std-future.C | 8 ++++++++ 6 files changed, 72 insertions(+) create mode 100644 gcc/testsuite/g++.dg/gnu-current.C create mode 100644 gcc/testsuite/g++.dg/gnu-future.C create mode 100644 gcc/testsuite/g++.dg/std-current.C create mode 100644 gcc/testsuite/g++.dg/std-future.C diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 44e1a60ce24..9292029a967 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -2321,6 +2321,14 @@ std=c++23 C++ ObjC++ Undocumented Conform to the ISO 2023 C++ draft standard (experimental and incomplete support). +std=c++current +C++ ObjC++ Alias(std=c++20) Undocumented +Conform to the current ISO C++ standard (C++20). + +std=c++future +C++ ObjC++ Alias(std=c++23) Undocumented +Conform to a future ISO C++ standard (C++2b, experimentatl and incomplete support). + std=c11 C ObjC Conform to the ISO 2011 C standard. @@ -2407,6 +2415,14 @@ std=gnu++23 C++ ObjC++ Undocumented Conform to the ISO 2023 C++ draft standard with GNU extensions (experimental and incomplete support). +std=gnu++current +C++ ObjC++ Alias(std=gnu++20) Undocumented +Conform to the current ISO C++ standard with GNU extensions (C++20). + +std=gnu++future +C++ ObjC++ Alias(std=gnu++23) Undocumented +Conform to a future ISO C++ standard with GNU extensions (C++2b, experimentatl and incomplete support). + std=gnu11 C ObjC Conform to the ISO 2011 C standard with GNU extensions. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d5ff1018372..1c0edb9df68 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2462,6 +2462,17 @@ GNU dialect of @option{-std=c++17}. This is the default for C++ code. The name @samp{gnu++1z} is deprecated. +@item gnu++current +@itemx gnu++current +GNU dialect of the current C++ standard, currently @option{-std=gnu++20}. +The C++ version selected by this option is a moving target. + +@item gnu++future +@itemx gnu++future +GNU dialect of the next C++ standard, currently @option{-std=gnu++2b}. +The C++ version selected by this option is a moving target (as are the +semantics of that proposed version). + @item c++20 @itemx c++2a The 2020 ISO C++ standard plus amendments. @@ -2487,6 +2498,18 @@ change in incompatible ways in future releases. GNU dialect of @option{-std=c++2b}. Support is highly experimental, and will almost certainly change in incompatible ways in future releases. + +@item c++current +@itemx c++current +The current C++ standard, currently @option{-std=gnu++20}. +The C++ version selected by this option is a moving target. + +@item c++future +@itemx c++future +The next C++ standard, currently @option{-std=gnu++2b}. +The C++ version selected by this option is a moving target (as are the +semantics of that proposed version). + @end table @item -aux-info @var{filename} diff --git a/gcc/testsuite/g++.dg/gnu-current.C b/gcc/testsuite/g++.dg/gnu-current.C new file mode 100644 index 00000000000..c95c56d3ad8 --- /dev/null +++ b/gcc/testsuite/g++.dg/gnu-current.C @@ -0,0 +1,7 @@ +// { dg-do compile } +// { dg-options -std=gnu++current } + +static_assert (__cplusplus == 202002L, "time has moved on"); +#if __STRICT_ANSI__ +#error "__STRICT_ANSI__ surprisingly non-zero" +#endif diff --git a/gcc/testsuite/g++.dg/gnu-future.C b/gcc/testsuite/g++.dg/gnu-future.C new file mode 100644 index 00000000000..366dcdeebc2 --- /dev/null +++ b/gcc/testsuite/g++.dg/gnu-future.C @@ -0,0 +1,7 @@ +// { dg-do compile } +// { dg-options -std=gnu++future } + +static_assert (__cplusplus > 202002L, "time has moved on"); +#if __STRICT_ANSI__ +#error "__STRICT_ANSI__ surprisingly non-zero" +#endif diff --git a/gcc/testsuite/g++.dg/std-current.C b/gcc/testsuite/g++.dg/std-current.C new file mode 100644 index 00000000000..334ffd1d2c4 --- /dev/null +++ b/gcc/testsuite/g++.dg/std-current.C @@ -0,0 +1,11 @@ +// { dg-do compile } +// { dg-options -std=c++current } + +// Adust as tomorrow and tomorrow and tomorrow +// Creeps in this petty pace from day to day +// To the last syllable of recorded time. + +static_assert (__cplusplus == 202002L, "time has moved on"); +#if !__STRICT_ANSI__ +#error "__STRICT_ANSI__ surprisingly zero" +#endif diff --git a/gcc/testsuite/g++.dg/std-future.C b/gcc/testsuite/g++.dg/std-future.C new file mode 100644 index 00000000000..dade97e6a71 --- /dev/null +++ b/gcc/testsuite/g++.dg/std-future.C @@ -0,0 +1,8 @@ +// { dg-do compile } +// { dg-options -std=c++future } + +static_assert (__cplusplus > 202002L, "time has moved on"); +#if !__STRICT_ANSI__ +#error "__STRICT_ANSI__ surprisingly zero" +#endif + -- 2.30.2