ginclude: C2x header version macros

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.

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.
This commit is contained in:
Joseph Myers 2022-11-13 12:58:49 +00:00
parent 05432288d4
commit 9a265c974c
18 changed files with 151 additions and 0 deletions

View file

@ -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___ */

View file

@ -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_ */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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___ */

View file

@ -0,0 +1,9 @@
/* Test __STDC_VERSION_FLOAT_H__ not in C11. */
/* { dg-do preprocess } */
/* { dg-options "-std=c11 -pedantic-errors" } */
#include <float.h>
#ifdef __STDC_VERSION_FLOAT_H__
#error "__STDC_VERSION_FLOAT_H__ defined"
#endif

View file

@ -0,0 +1,9 @@
/* Test __STDC_VERSION_LIMITS_H__ not in C11. */
/* { dg-do preprocess } */
/* { dg-options "-std=c11 -pedantic-errors" } */
#include <limits.h>
#ifdef __STDC_VERSION_LIMITS_H__
#error "__STDC_VERSION_LIMITS_H__ defined"
#endif

View file

@ -0,0 +1,9 @@
/* Test __STDC_VERSION_STDARG_H__ not in C11. */
/* { dg-do preprocess } */
/* { dg-options "-std=c11 -pedantic-errors" } */
#include <stdarg.h>
#ifdef __STDC_VERSION_STDARG_H__
#error "__STDC_VERSION_STDARG_H__ defined"
#endif

View file

@ -0,0 +1,9 @@
/* Test __STDC_VERSION_STDATOMIC_H__ not in C11. */
/* { dg-do preprocess } */
/* { dg-options "-std=c11 -pedantic-errors" } */
#include <stdatomic.h>
#ifdef __STDC_VERSION_STDATOMIC_H__
#error "__STDC_VERSION_STDATOMIC_H__ defined"
#endif

View file

@ -0,0 +1,9 @@
/* Test __STDC_VERSION_STDDEF_H__ not in C11. */
/* { dg-do preprocess } */
/* { dg-options "-std=c11 -pedantic-errors" } */
#include <stddef.h>
#ifdef __STDC_VERSION_STDDEF_H__
#error "__STDC_VERSION_STDDEF_H__ defined"
#endif

View file

@ -0,0 +1,9 @@
/* Test __STDC_VERSION_STDINT_H__ not in C11. */
/* { dg-do preprocess } */
/* { dg-options "-std=c11 -pedantic-errors -ffreestanding" } */
#include <stdint.h>
#ifdef __STDC_VERSION_STDINT_H__
#error "__STDC_VERSION_STDINT_H__ defined"
#endif

View file

@ -0,0 +1,13 @@
/* Test __STDC_VERSION_FLOAT_H__ in C2x. */
/* { dg-do preprocess } */
/* { dg-options "-std=c2x -pedantic-errors" } */
#include <float.h>
#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

View file

@ -0,0 +1,13 @@
/* Test __STDC_VERSION_LIMITS_H__ in C2x. */
/* { dg-do preprocess } */
/* { dg-options "-std=c2x -pedantic-errors" } */
#include <limits.h>
#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

View file

@ -0,0 +1,13 @@
/* Test __STDC_VERSION_STDARG_H__ in C2x. */
/* { dg-do preprocess } */
/* { dg-options "-std=c2x -pedantic-errors" } */
#include <stdarg.h>
#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

View file

@ -0,0 +1,13 @@
/* Test __STDC_VERSION_STDATOMIC_H__ in C2x. */
/* { dg-do preprocess } */
/* { dg-options "-std=c2x -pedantic-errors" } */
#include <stdatomic.h>
#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

View file

@ -0,0 +1,13 @@
/* Test __STDC_VERSION_STDDEF_H__ in C2x. */
/* { dg-do preprocess } */
/* { dg-options "-std=c2x -pedantic-errors" } */
#include <stddef.h>
#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

View file

@ -0,0 +1,13 @@
/* Test __STDC_VERSION_STDINT_H__ in C2x. */
/* { dg-do preprocess } */
/* { dg-options "-std=c2x -pedantic-errors -ffreestanding" } */
#include <stdint.h>
#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