From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Type: text/plain; charset="US-ASCII" 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 List-Id: 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 -- Joseph S. Myers joseph@codesourcery.com