From: Joseph Myers Date: Wed, 16 Oct 2024 10:37:10 +0000 (+0000) Subject: testsuite: Add tests for C23 __STDC_VERSION__ X-Git-Tag: basepoints/gcc-16~5173 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65abc81c3982631255799e4a666a5dd5b03dc817;p=thirdparty%2Fgcc.git 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 --git a/gcc/testsuite/gcc.dg/c23-version-1.c b/gcc/testsuite/gcc.dg/c23-version-1.c new file mode 100644 index 00000000000..2145f974297 --- /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 00000000000..3d44b7324c9 --- /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 00000000000..649f13b54ec --- /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