aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c23-nullptr-6.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/c23-nullptr-6.c')
-rw-r--r--gcc/testsuite/gcc.dg/c23-nullptr-6.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/c23-nullptr-6.c b/gcc/testsuite/gcc.dg/c23-nullptr-6.c
new file mode 100644
index 0000000..2ee2202
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c23-nullptr-6.c
@@ -0,0 +1,33 @@
+/* PR c/108424 */
+/* { dg-options "-std=c23" } */
+
+struct S {
+ int i;
+ int : nullptr; /* { dg-error "not an integer constant" } */
+};
+
+enum E { X = nullptr }; /* { dg-error "not an integer constant" } */
+
+alignas(nullptr) int g; /* { dg-error "not an integer constant" } */
+
+int arr[10] = { [nullptr] = 1 }; /* { dg-error "not of integer type" } */
+
+_Static_assert (nullptr, "nullptr"); /* { dg-error "not an integer" } */
+
+void f (int n)
+{
+ switch (n) {
+ case nullptr: /* { dg-error "an integer constant" } */
+ default:
+ }
+
+ switch (n) {
+ case 1 ... nullptr: /* { dg-error "an integer constant" } */
+ default:
+ }
+
+ switch (n) {
+ case nullptr ... 2: /* { dg-error "an integer constant" } */
+ default:
+ }
+}