aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorGeoff Johnstone <geoff.johnstone@googlemail.com>2008-04-21 11:53:48 -0700
committerJosh Triplett <josh@freedesktop.org>2008-04-21 11:53:48 -0700
commit32dd96be4de207b09559d9b71c4cd6f7cb0cb4e2 (patch)
treeb73d3dece1a2f38f3a6daf78ac4c4d51691322f2 /validation
parent6663e10782e0bd57c028dd4fb70531bff782e926 (diff)
downloadsparse-dev-32dd96be4de207b09559d9b71c4cd6f7cb0cb4e2.tar.gz
Add -Wno-declaration-after-statement
This adds -W[no-]declaration-after-statement, which makes warnings about declarations after statements a command-line option. (The code to implement the warning was already in there via a #define; the patch just exposes it at runtime.) Rationale: C99 allows them, C89 doesn't. Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/declaration-after-statement-ansi.c12
-rw-r--r--validation/declaration-after-statement-c89.c12
-rw-r--r--validation/declaration-after-statement-c99.c9
-rw-r--r--validation/declaration-after-statement-default.c9
4 files changed, 42 insertions, 0 deletions
diff --git a/validation/declaration-after-statement-ansi.c b/validation/declaration-after-statement-ansi.c
new file mode 100644
index 00000000..333410b7
--- /dev/null
+++ b/validation/declaration-after-statement-ansi.c
@@ -0,0 +1,12 @@
+static void func (int i)
+{
+ i;
+ int j = i;
+}
+/*
+ * check-name: declaration after statement (ANSI)
+ * check-command: sparse -ansi $file
+ * check-error-start
+declaration-after-statement-ansi.c:4:2: warning: mixing declarations and code
+ * check-error-end
+ */
diff --git a/validation/declaration-after-statement-c89.c b/validation/declaration-after-statement-c89.c
new file mode 100644
index 00000000..78632cd9
--- /dev/null
+++ b/validation/declaration-after-statement-c89.c
@@ -0,0 +1,12 @@
+static void func (int i)
+{
+ i;
+ int j = i;
+}
+/*
+ * check-name: declaration after statement (C89)
+ * check-command: sparse -std=c89 $file
+ * check-error-start
+declaration-after-statement-c89.c:4:2: warning: mixing declarations and code
+ * check-error-end
+ */
diff --git a/validation/declaration-after-statement-c99.c b/validation/declaration-after-statement-c99.c
new file mode 100644
index 00000000..dd36e6ef
--- /dev/null
+++ b/validation/declaration-after-statement-c99.c
@@ -0,0 +1,9 @@
+static void func (int i)
+{
+ i;
+ int j = i;
+}
+/*
+ * check-name: declaration after statement (C99)
+ * check-command: sparse -std=c99 $file
+ */
diff --git a/validation/declaration-after-statement-default.c b/validation/declaration-after-statement-default.c
new file mode 100644
index 00000000..c3fe2cd2
--- /dev/null
+++ b/validation/declaration-after-statement-default.c
@@ -0,0 +1,9 @@
+static void func (int i)
+{
+ i;
+ int j = i;
+}
+/*
+ * check-name: declaration after statement (default)
+ * check-command: sparse $file
+ */