@@ -8,3 +8,24 @@
#define H(x...,y)
#define I(...+
#define J(x,y)
+/*
+ * check-name: Preprocessor #11
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+
+ * check-output-end
+ *
+ * check-error-start
+preprocessor/preprocessor11.c:1:11: error: "1" may not appear in macro parameter list
+preprocessor/preprocessor11.c:2:11: error: missing ')' in macro parameter list
+preprocessor/preprocessor11.c:3:12: error: missing ')' in macro parameter list
+preprocessor/preprocessor11.c:4:11: error: parameter name missing
+preprocessor/preprocessor11.c:5:11: error: __VA_ARGS__ can only appear in the expansion of a C99 variadic macro
+preprocessor/preprocessor11.c:6:12: error: "+" may not appear in macro parameter list
+preprocessor/preprocessor11.c:7:12: error: missing ')' in macro parameter list
+preprocessor/preprocessor11.c:8:12: error: missing ')' in macro parameter list
+preprocessor/preprocessor11.c:9:11: error: missing ')' in macro parameter list
+ * check-error-end
+ */
@@ -5,3 +5,14 @@
A(1)
A(1,2)
A(1,2,3)
+/*
+ * check-name: Preprocessor #12
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+1
+1,2
+1,2,3
+ * check-output-end
+ */
@@ -5,3 +5,19 @@
A(1)
A(1,2)
A(1,2,3)
+/*
+ * check-name: Preprocessor #13
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+1
+1,2
+1,2,3
+ * check-output-end
+ *
+ * check-error-start
+preprocessor/preprocessor13.c:6:1: error: '##' failed: concatenation is not a valid token
+preprocessor/preprocessor13.c:7:1: error: '##' failed: concatenation is not a valid token
+ * check-error-end
+ */
@@ -5,3 +5,13 @@
A(,1)
#define B(x,y,...) x##,##__VA_ARGS__
B(,1)
+/*
+ * check-name: Preprocessor #14
+ * check-known-to-fail
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+
+ * check-output-end
+ */
@@ -5,3 +5,12 @@
#if D(A,B) B
D(1,2)
#endif
+/*
+ * check-name: Preprocessor #15
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+12
+ * check-output-end
+ */
@@ -19,3 +19,12 @@ they hit before we get to the level of groups.
#bullshit
#endif
+/*
+ * check-name: Preprocessor #16
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+
+ * check-output-end
+ */
new file mode 100644
@@ -0,0 +1,35 @@
+#define CONFIG_FOO 1
+
+#define define_struct(name, fields...) struct fields name;
+
+define_struct(a, {
+#ifdef CONFIG_FOO
+ int b;
+#elif defined(CONFIG_BAR)
+ int c;
+#else
+ int d;
+#endif
+});
+/*
+ * check-name: Preprocessor #22
+ *
+ * check-description: Directives are not allowed within a macro argument list,
+ * although cpp deals with it to treat macro more like C functions.
+ *
+ * check-command: sparse -E $file
+ *
+ * check-error-start
+preprocessor/preprocessor22.c:6:1: error: directive in argument list
+preprocessor/preprocessor22.c:8:1: error: directive in argument list
+preprocessor/preprocessor22.c:10:1: error: directive in argument list
+preprocessor/preprocessor22.c:12:1: error: directive in argument list
+ * check-error-end
+ *
+ * check-output-start
+
+struct {
+int b;
+} a;;
+ * check-output-end
+ */
@@ -3,3 +3,12 @@
#define C(x,y) E(y)
#define E(y) #y
A(2))
+/*
+ * check-name: Preprocessor #7
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+"\"D\""
+ * check-output-end
+ */
@@ -14,3 +14,25 @@
"x#y" : E
"ab GH \"G\" 12" : F(G,H)
"a ## b" : I(a,##,b)
+/*
+ * check-name: Preprocessor #8
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+"A(x)" : A(x)
+"B(x)" : B(x)
+"C(x)" : C(x)
+"D(x)" : D(x)
+"x#y" : x#y
+"ab GH \"G\" 12" : ab GH "G" 12
+"a ## b" : a ## b
+ * check-output-end
+ *
+ * check-error-start
+preprocessor/preprocessor8.c:1:14: error: '##' cannot appear at the ends of macro expansion
+preprocessor/preprocessor8.c:2:16: error: '##' cannot appear at the ends of macro expansion
+preprocessor/preprocessor8.c:3:22: error: '##' cannot appear at the ends of macro expansion
+preprocessor/preprocessor8.c:4:15: error: '#' is not followed by a macro parameter
+ * check-error-end
+ */
Instrument validate/preprocessor/preproprocessor*.c to be integrated into the test-suite where missing and add an additional test case. Signed-off-by: Hannes Eder <hannes@hanneseder.net> --- It's a little bit unclear to me how to deal with preprocessor14.c. Sparse and cpp disagree on the output to produce. $ sparse -E preprocessor14.c > preprocessor14.sparse $ cpp -P preprocessor14.c > preprocessor14.cpp $ diff -u preprocessor14.cpp preprocessor14.sparse |> --- preprocessor14.cpp 2009-03-11 01:08:34.000000000 +0100 |> +++ preprocessor14.sparse 2009-03-11 01:05:39.000000000 +0100 |> @@ -1,9 +1,2 @@ |> |> - |> - |> - |> - |> - |> - |> - |> - |> +, Ok there is a difference in the number of empty lines, who cares, but spares outputs a "," and cpp does not. Could somebody with more insight comment on this? Al? :) Meanwhile I marked this test as "check-known-to-fail". validation/preprocessor/preprocessor11.c | 21 ++++++++++++++++++ validation/preprocessor/preprocessor12.c | 11 +++++++++ validation/preprocessor/preprocessor13.c | 16 ++++++++++++++ validation/preprocessor/preprocessor14.c | 10 +++++++++ validation/preprocessor/preprocessor15.c | 9 ++++++++ validation/preprocessor/preprocessor16.c | 9 ++++++++ validation/preprocessor/preprocessor22.c | 35 ++++++++++++++++++++++++++++++ validation/preprocessor/preprocessor7.c | 9 ++++++++ validation/preprocessor/preprocessor8.c | 22 +++++++++++++++++++ 9 files changed, 142 insertions(+), 0 deletions(-) create mode 100644 validation/preprocessor/preprocessor22.c -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html