https://gcc.gnu.org/g:65abc81c3982631255799e4a666a5dd5b03dc817
commit r15-4380-g65abc81c3982631255799e4a666a5dd5b03dc817 Author: Joseph Myers <josmy...@redhat.com> Date: Wed Oct 16 10:37:10 2024 +0000 testsuite: Add tests for C23 __STDC_VERSION__ Add some tests for the value of __STDC_VERSION__ in C23 mode. Bootstrapped with no regressions for x86_64-pc-linux-gnu. * gcc.dg/c23-version-1.c, gcc.dg/c23-version-2.c, gcc.dg/gnu23-version-1.c: New tests. Diff: --- gcc/testsuite/gcc.dg/c23-version-1.c | 9 +++++++++ gcc/testsuite/gcc.dg/c23-version-2.c | 9 +++++++++ gcc/testsuite/gcc.dg/gnu23-version-1.c | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/gcc/testsuite/gcc.dg/c23-version-1.c b/gcc/testsuite/gcc.dg/c23-version-1.c new file mode 100644 index 000000000000..2145f9742973 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C23. Test -std=c23. */ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 202311L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/gcc/testsuite/gcc.dg/c23-version-2.c b/gcc/testsuite/gcc.dg/c23-version-2.c new file mode 100644 index 000000000000..3d44b7324c9b --- /dev/null +++ b/gcc/testsuite/gcc.dg/c23-version-2.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C23. Test -std=iso9899:2024. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:2024 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 202311L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif diff --git a/gcc/testsuite/gcc.dg/gnu23-version-1.c b/gcc/testsuite/gcc.dg/gnu23-version-1.c new file mode 100644 index 000000000000..649f13b54ec5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu23-version-1.c @@ -0,0 +1,9 @@ +/* Test __STDC_VERSION__ for C23 with GNU extensions. Test -std=gnu23. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu23 -pedantic-errors" } */ + +#if __STDC_VERSION__ == 202311L +int i; +#else +#error "Bad __STDC_VERSION__." +#endif