]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Add tests for C23 __STDC_VERSION__
authorJoseph Myers <josmyers@redhat.com>
Wed, 16 Oct 2024 10:37:10 +0000 (10:37 +0000)
committerJoseph Myers <josmyers@redhat.com>
Wed, 16 Oct 2024 10:37:10 +0000 (10:37 +0000)
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.

gcc/testsuite/gcc.dg/c23-version-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c23-version-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gnu23-version-1.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/c23-version-1.c b/gcc/testsuite/gcc.dg/c23-version-1.c
new file mode 100644 (file)
index 0000000..2145f97
--- /dev/null
@@ -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 (file)
index 0000000..3d44b73
--- /dev/null
@@ -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 (file)
index 0000000..649f13b
--- /dev/null
@@ -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