aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-03-19 20:02:09 +0100
committerlemon <lsof@mailbox.org>2026-03-19 20:02:09 +0100
commit0e1a2a18ac7056e7fe3a033b664e6ecb8faba651 (patch)
tree470f8e423f5e4ab10faf5e9c4e294121b7cac0dc /test
parent05e132851016d566629fcfd279eef025a14ddb32 (diff)
c: fix qualifiers for array declarators
`const int x[]` was being treated as `const int x[const]`, which is wrong, and matters when `x` is a function parameter that really decays to a pointer (`int const *const x`)
Diffstat (limited to 'test')
-rw-r--r--test/17-misc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/17-misc.c b/test/17-misc.c
index cec45b4..e6f9d11 100644
--- a/test/17-misc.c
+++ b/test/17-misc.c
@@ -52,6 +52,12 @@ struct S3 {
char q;
};
+int array_const_decay(const char x[3], int i) {
+ static const char y[3] = "11";
+ if (!x) x = y;
+ return x[i];
+}
+
extern int printf(const char *, ...);
#include <assert.h>
#include <string.h>