From patchwork Fri Sep 9 20:41:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 1124 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp887146wrt; Fri, 9 Sep 2022 13:41:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR4craAlTHwsVNXbZ4NcXCeWSISrN3NG1F+nBuC/lBTFc4EgPluWs8ug37a4nM5uGNjKAYvz X-Received: by 2002:a17:907:7e8e:b0:741:362a:9678 with SMTP id qb14-20020a1709077e8e00b00741362a9678mr10541681ejc.499.1662756106507; Fri, 09 Sep 2022 13:41:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662756106; cv=none; d=google.com; s=arc-20160816; b=tIFUNGaQ1Ym5FJx3frXd9S95H5KmrsJz0UZQeCjSyjueAcsJwrOdE4ZQWSvmMe+crj 6AaZT6HzSBM5/MgMVIQHGo/yS9lHa9mNAnICTqahq1//GvCN7NdGBOHC7Ar6PftABX/V 9OtfyGYL5gzj5jfK1Yz0z9K9lV7/WTiwaDcXRESKyIxTywcW35RmQVj9mjwR+lDxHhoV u6ArW+mO6yNqzJ279sF9cjcURNlilWqx/ZfY693qjiLfzRayLhSW8YfmcdJjUx2+dg9Y ozUfey6/fRteDtMRvd5T4sUmy3Fr+lz2W6Hh0LGy9m3iuVpJkeNMKILM4mp6V82n/2+p TIvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:subject:to:from:date:ironport-sdr:dmarc-filter :delivered-to; bh=biDcQ/tbZ6ql2YYmgitvf+tYcJE253iXckmo4M0fRgU=; b=vJFsIrCxNzHhTEamjbP4BHz6y9mjqJ4ToOSfdDOrCPlrwqBDz2LzwnfIBLe2yHbcAj CAbVgAtxnKBGHyQ6CqVqGWv78EsQs1YcXu+Dk3AgtFaSCAbUqgeHc2M/P2ytY7XnZVIK xEvjjAiJ7adZ/aOej6EwCyfTG0fLgULHqwkGKyoN8xi/ftgritHuO+lDoQV5gC4wSx0b Af5B4xHnASb0BPnfTHbYgylLjEtObNaRCOxPOxPD34MR3cY6VK6hvuZZAVx+9R9QFAJk jGH0NVuj1FoXodWoTGNpQB/CTOyi8bInNiScqDvGqI2RBjFzZDO9DPnzd+e3Y41EHYGQ h3qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r6-20020a05640251c600b004477532706bsi1366615edd.517.2022.09.09.13.41.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 13:41:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 2C8CD3857365 for ; Fri, 9 Sep 2022 20:41:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 004D83858429 for ; Fri, 9 Sep 2022 20:41:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 004D83858429 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.93,304,1654588800"; d="scan'208";a="85510636" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 09 Sep 2022 12:41:10 -0800 IronPort-SDR: 1sB6gu1su2EIq61+c3wucAOLJz3JpcRTvedk48UpBxp9HFErNvjDEbEXikFur8c3uOX//qPpY1 Mb/5nZF5IxmOZ90AokAX8hehOQYANdOQqGh22kA4Bq5K+3E9LUV2oogGKGAe5SqKd8UhsO2HRd KAws0UWwIMzmWLWN7FW84/vg9nhyD2on1OTtjm+LjwnWRl1s7vxEnr1i+niZpd53x8y9poNu/2 3afIHi6Tut8DueU1JJuzAm5jxEVP9ulO4KwUhzlozV9ZObK1h5Zb5a4K1C22eRSTUz6dtZpFb+ VYs= Date: Fri, 9 Sep 2022 20:41:06 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Subject: stdatomic.h: Do not define ATOMIC_VAR_INIT for C2x Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3117.3 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.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743526147381471907?= X-GMAIL-MSGID: =?utf-8?q?1743526147381471907?= The macro ATOMIC_VAR_INIT, previously declared obsolete, is removed completely in C2x; disable it for C2x in GCC's implementation. (Although ATOMIC_* are reserved names for this header, disabling the macro for C2x still seems appropriate.) Bootstrapped with no regressions for x86_64-pc-linux-gnu. OK to commit? gcc/ * ginclude/stdatomic.h [defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L] (ATOMIC_VAR_INIT): Do not define. gcc/testsuite/ * gcc.dg/atomic/c2x-stdatomic-var-init-1.c: New test. diff --git a/gcc/ginclude/stdatomic.h b/gcc/ginclude/stdatomic.h index 9f2475b739d..a56ba5d9639 100644 --- a/gcc/ginclude/stdatomic.h +++ b/gcc/ginclude/stdatomic.h @@ -79,7 +79,9 @@ typedef _Atomic __INTMAX_TYPE__ atomic_intmax_t; typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; +#if !(defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L) #define ATOMIC_VAR_INIT(VALUE) (VALUE) +#endif /* Initialize an atomic object pointed to by PTR with VAL. */ #define atomic_init(PTR, VAL) \ diff --git a/gcc/testsuite/gcc.dg/atomic/c2x-stdatomic-var-init-1.c b/gcc/testsuite/gcc.dg/atomic/c2x-stdatomic-var-init-1.c new file mode 100644 index 00000000000..1978a410350 --- /dev/null +++ b/gcc/testsuite/gcc.dg/atomic/c2x-stdatomic-var-init-1.c @@ -0,0 +1,9 @@ +/* Test ATOMIC_VAR_INIT not in C2x. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifdef ATOMIC_VAR_INIT +#error "ATOMIC_VAR_INIT defined" +#endif