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: 1676243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPSZm6m4nz1yp6 for ; Sat, 10 Sep 2022 06:41:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB2D0385735D for ; Fri, 9 Sep 2022 20:41:28 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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