From patchwork Sat Nov 12 18:18:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 1703133 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 4N8kNN465tz23n2 for ; Sun, 13 Nov 2022 05:18:42 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E78DD3882111 for ; Sat, 12 Nov 2022 18:18:39 +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 8BD3C3858410 for ; Sat, 12 Nov 2022 18:18:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8BD3C3858410 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.96,160,1665475200"; d="scan'208";a="86961654" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 12 Nov 2022 10:18:23 -0800 IronPort-SDR: dTIrh+UJ+vu9+0XPiSC3as15S7msDw0KP22iuO5zbjtsnXWSEB0H3v12sMPxHr9mHC79fKRReW D8ns5ExNIXaEpMS2trbQ7AleaEEw+USmRa4GzXEtrVYHfUvMMqO1GZezjyIo9w84UItotKcaRd eos+q9To49jRGJ19dkPjV3QdWQOmNVyy4m3GDJnPZR8lwQdDQGdikvwazIEJ2s1jjbQEN/e6ML XgefzN5HfA4rT1lAaOJ7/O84Ccc+imGKPtzF0W4WdE26hVLctqfmLZFsbXa/sKXvLEwVnqJBC6 p3U= Date: Sat, 12 Nov 2022 18:18:18 +0000 From: Joseph Myers To: Subject: ginclude: C2x header version macros Message-ID: <77db8c82-5856-2c9c-7583-8534e0c92ee4@codesourcery.com> 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=-3116.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP 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" C2x adds __STDC_VERSION_*_H__ macros to individual headers with interface changes compared to C17. All the new header features in headers provided by GCC have now been implemented, so define those macros to the value given in the current working draft. Bootstrapped with no regressions for x86_64-pc-linux-gnu. OK to commit? gcc/ * ginclude/float.h [__STDC_VERSION__ > 201710L] (__STDC_VERSION_FLOAT_H__): New macro. * ginclude/stdarg.h [__STDC_VERSION__ > 201710L] (__STDC_VERSION_STDARG_H__): New macro. * ginclude/stdatomic.h [__STDC_VERSION__ > 201710L] (__STDC_VERSION_STDATOMIC_H__): New macro. * ginclude/stddef.h [__STDC_VERSION__ > 201710L] (__STDC_VERSION_STDDEF_H__): New macro. * ginclude/stdint-gcc.h [__STDC_VERSION__ > 201710L] (__STDC_VERSION_STDINT_H__): New macro. * glimits.h [__STDC_VERSION__ > 201710L] (__STDC_VERSION_LIMITS_H__): New macro. gcc/testsuite/ * gcc.dg/c11-float-8.c, gcc.dg/c11-limits-1.c, gcc.dg/c11-stdarg-4.c, gcc.dg/c11-stdatomic-3.c, gcc.dg/c11-stddef-1.c, gcc.dg/c11-stdint-1.c, gcc.dg/c2x-float-13.c, gcc.dg/c2x-limits-1.c, gcc.dg/c2x-stdarg-5.c, gcc.dg/c2x-stdatomic-1.c, gcc.dg/c2x-stddef-1.c, gcc.dg/c2x-stdint-1.c: New tests. diff --git a/gcc/ginclude/float.h b/gcc/ginclude/float.h index bc5439d664f..172b9de477f 100644 --- a/gcc/ginclude/float.h +++ b/gcc/ginclude/float.h @@ -624,4 +624,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif /* __DEC32_MANT_DIG__ */ +#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L +#define __STDC_VERSION_FLOAT_H__ 202311L +#endif + #endif /* _FLOAT_H___ */ diff --git a/gcc/ginclude/stdarg.h b/gcc/ginclude/stdarg.h index c704c9ffcf2..5149f7b3f4f 100644 --- a/gcc/ginclude/stdarg.h +++ b/gcc/ginclude/stdarg.h @@ -125,6 +125,10 @@ typedef __gnuc_va_list va_list; #endif /* not __svr4__ */ +#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L +#define __STDC_VERSION_STDARG_H__ 202311L +#endif + #endif /* _STDARG_H */ #endif /* not _ANSI_STDARG_H_ */ diff --git a/gcc/ginclude/stdatomic.h b/gcc/ginclude/stdatomic.h index a56ba5d9639..e16b072ccde 100644 --- a/gcc/ginclude/stdatomic.h +++ b/gcc/ginclude/stdatomic.h @@ -248,4 +248,8 @@ extern void atomic_flag_clear (volatile atomic_flag *); extern void atomic_flag_clear_explicit (volatile atomic_flag *, memory_order); #define atomic_flag_clear_explicit(PTR, MO) __atomic_clear ((PTR), (MO)) +#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L +#define __STDC_VERSION_STDATOMIC_H__ 202311L +#endif + #endif /* _STDATOMIC_H */ diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h index 2767edf51de..7980045e712 100644 --- a/gcc/ginclude/stddef.h +++ b/gcc/ginclude/stddef.h @@ -454,6 +454,7 @@ typedef struct { #if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L #define unreachable() (__builtin_unreachable ()) +#define __STDC_VERSION_STDDEF_H__ 202311L #endif #endif /* _STDDEF_H was defined this time */ diff --git a/gcc/ginclude/stdint-gcc.h b/gcc/ginclude/stdint-gcc.h index 6be01ae28b8..eab651d968a 100644 --- a/gcc/ginclude/stdint-gcc.h +++ b/gcc/ginclude/stdint-gcc.h @@ -362,4 +362,8 @@ typedef __UINTMAX_TYPE__ uintmax_t; #endif +#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L +#define __STDC_VERSION_STDINT_H__ 202311L +#endif + #endif /* _GCC_STDINT_H */ diff --git a/gcc/glimits.h b/gcc/glimits.h index 8d74c8b88d6..994f7e33bbe 100644 --- a/gcc/glimits.h +++ b/gcc/glimits.h @@ -156,6 +156,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define BOOL_MAX 1 # undef BOOL_WIDTH # define BOOL_WIDTH 1 + +# define __STDC_VERSION_LIMITS_H__ 202311L #endif #endif /* _LIMITS_H___ */ diff --git a/gcc/testsuite/gcc.dg/c11-float-8.c b/gcc/testsuite/gcc.dg/c11-float-8.c new file mode 100644 index 00000000000..7fb1e0a5683 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-float-8.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_FLOAT_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef __STDC_VERSION_FLOAT_H__ +#error "__STDC_VERSION_FLOAT_H__ defined" +#endif diff --git a/gcc/testsuite/gcc.dg/c11-limits-1.c b/gcc/testsuite/gcc.dg/c11-limits-1.c new file mode 100644 index 00000000000..6dc5737024d --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-limits-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_LIMITS_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef __STDC_VERSION_LIMITS_H__ +#error "__STDC_VERSION_LIMITS_H__ defined" +#endif diff --git a/gcc/testsuite/gcc.dg/c11-stdarg-4.c b/gcc/testsuite/gcc.dg/c11-stdarg-4.c new file mode 100644 index 00000000000..06bff1f0445 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-stdarg-4.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_STDARG_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef __STDC_VERSION_STDARG_H__ +#error "__STDC_VERSION_STDARG_H__ defined" +#endif diff --git a/gcc/testsuite/gcc.dg/c11-stdatomic-3.c b/gcc/testsuite/gcc.dg/c11-stdatomic-3.c new file mode 100644 index 00000000000..1f5a71b6219 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-stdatomic-3.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_STDATOMIC_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef __STDC_VERSION_STDATOMIC_H__ +#error "__STDC_VERSION_STDATOMIC_H__ defined" +#endif diff --git a/gcc/testsuite/gcc.dg/c11-stddef-1.c b/gcc/testsuite/gcc.dg/c11-stddef-1.c new file mode 100644 index 00000000000..9918d9478c4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-stddef-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_STDDEF_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include + +#ifdef __STDC_VERSION_STDDEF_H__ +#error "__STDC_VERSION_STDDEF_H__ defined" +#endif diff --git a/gcc/testsuite/gcc.dg/c11-stdint-1.c b/gcc/testsuite/gcc.dg/c11-stdint-1.c new file mode 100644 index 00000000000..43fe681c7a5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c11-stdint-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION_STDINT_H__ not in C11. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c11 -pedantic-errors -ffreestanding" } */ + +#include + +#ifdef __STDC_VERSION_STDINT_H__ +#error "__STDC_VERSION_STDINT_H__ defined" +#endif diff --git a/gcc/testsuite/gcc.dg/c2x-float-13.c b/gcc/testsuite/gcc.dg/c2x-float-13.c new file mode 100644 index 00000000000..dc54bc734b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-float-13.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_FLOAT_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef __STDC_VERSION_FLOAT_H__ +#error "__STDC_VERSION_FLOAT_H__ not defined" +#endif + +#if __STDC_VERSION_FLOAT_H__ != 202311L +#error "bad value of __STDC_VERSION_FLOAT_H__" +#endif diff --git a/gcc/testsuite/gcc.dg/c2x-limits-1.c b/gcc/testsuite/gcc.dg/c2x-limits-1.c new file mode 100644 index 00000000000..4977faf47b4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-limits-1.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_LIMITS_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef __STDC_VERSION_LIMITS_H__ +#error "__STDC_VERSION_LIMITS_H__ not defined" +#endif + +#if __STDC_VERSION_LIMITS_H__ != 202311L +#error "bad value of __STDC_VERSION_LIMITS_H__" +#endif diff --git a/gcc/testsuite/gcc.dg/c2x-stdarg-5.c b/gcc/testsuite/gcc.dg/c2x-stdarg-5.c new file mode 100644 index 00000000000..134244357bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-stdarg-5.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_STDARG_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef __STDC_VERSION_STDARG_H__ +#error "__STDC_VERSION_STDARG_H__ not defined" +#endif + +#if __STDC_VERSION_STDARG_H__ != 202311L +#error "bad value of __STDC_VERSION_STDARG_H__" +#endif diff --git a/gcc/testsuite/gcc.dg/c2x-stdatomic-1.c b/gcc/testsuite/gcc.dg/c2x-stdatomic-1.c new file mode 100644 index 00000000000..3a9ceb0ea39 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-stdatomic-1.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_STDATOMIC_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef __STDC_VERSION_STDATOMIC_H__ +#error "__STDC_VERSION_STDATOMIC_H__ not defined" +#endif + +#if __STDC_VERSION_STDATOMIC_H__ != 202311L +#error "bad value of __STDC_VERSION_STDATOMIC_H__" +#endif diff --git a/gcc/testsuite/gcc.dg/c2x-stddef-1.c b/gcc/testsuite/gcc.dg/c2x-stddef-1.c new file mode 100644 index 00000000000..1ebdf2037ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-stddef-1.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_STDDEF_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +#include + +#ifndef __STDC_VERSION_STDDEF_H__ +#error "__STDC_VERSION_STDDEF_H__ not defined" +#endif + +#if __STDC_VERSION_STDDEF_H__ != 202311L +#error "bad value of __STDC_VERSION_STDDEF_H__" +#endif diff --git a/gcc/testsuite/gcc.dg/c2x-stdint-1.c b/gcc/testsuite/gcc.dg/c2x-stdint-1.c new file mode 100644 index 00000000000..3ba6ce56a7a --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-stdint-1.c @@ -0,0 +1,13 @@ +/* Test __STDC_VERSION_STDINT_H__ in C2x. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c2x -pedantic-errors -ffreestanding" } */ + +#include + +#ifndef __STDC_VERSION_STDINT_H__ +#error "__STDC_VERSION_STDINT_H__ not defined" +#endif + +#if __STDC_VERSION_STDINT_H__ != 202311L +#error "bad value of __STDC_VERSION_STDINT_H__" +#endif