aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>2013-05-16 20:44:11 +0100
committerChristopher Li <sparse@chrisli.org>2013-05-23 08:19:39 -0700
commit5a3bd40c1e9976c0896ad2d198e202a515dcf194 (patch)
treea682f05333b6628620474fc0546b207c62491e78 /validation
parent0edb7edecdd571c2663eb12acac1b27b9acac657 (diff)
downloadsparse-dev-5a3bd40c1e9976c0896ad2d198e202a515dcf194.tar.gz
symbol.c: Set correct size of array from parenthesized string initializer
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'validation')
-rw-r--r--validation/init-char-array1.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/validation/init-char-array1.c b/validation/init-char-array1.c
new file mode 100644
index 00000000..24fd8d82
--- /dev/null
+++ b/validation/init-char-array1.c
@@ -0,0 +1,27 @@
+/*
+ * for array of char, ("...") as the initializer is an gcc language
+ * extension. check that a parenthesized string initializer is handled
+ * correctly and that -Wparen-string warns about it's use.
+ */
+static const char u[] = ("hello");
+static const char v[] = {"hello"};
+static const char v1[] = {("hello")};
+static const char w[] = "hello";
+static const char x[5] = "hello";
+
+static void f(void)
+{
+ char a[1/(sizeof(u) == 6)];
+ char b[1/(sizeof(v) == 6)];
+ char c[1/(sizeof(w) == 6)];
+ char d[1/(sizeof(x) == 5)];
+}
+/*
+ * check-name: parenthesized string initializer
+ * check-command: sparse -Wparen-string $file
+ *
+ * check-error-start
+init-char-array1.c:6:26: warning: array initialized from parenthesized string constant
+init-char-array1.c:8:28: warning: array initialized from parenthesized string constant
+ * check-error-end
+ */