aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorAl Viro <viro@zeniv.linux.org.uk>2013-01-07 14:00:48 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-12 10:05:31 -0500
commit959bd8973bfcfced69715a522007662929ae6d48 (patch)
tree18c00b9c8fde48546638c613e4db9d0fa84d06c6 /validation
parent15cfba61d99668e9c14782779766f48834490ead (diff)
downloadsparse-dev-959bd8973bfcfced69715a522007662929ae6d48.tar.gz
switch to delayed handling of escape sequences
#define A(x) #x A('\12') should *not* yield "'\\n'"; the problem is that we are doing the conversion too early. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'validation')
-rw-r--r--validation/escapes.c17
-rw-r--r--validation/preprocessor/stringify.c29
2 files changed, 37 insertions, 9 deletions
diff --git a/validation/escapes.c b/validation/escapes.c
index 13f8f9c8..4a1b030e 100644
--- a/validation/escapes.c
+++ b/validation/escapes.c
@@ -8,14 +8,13 @@ static int bad_e[] = { '\c', '\0123', '\789', '\xdefg' };
* check-name: Character escape sequences
*
* check-error-start
-escapes.c:6:27: warning: Unknown escape 'c'
-escapes.c:6:35: error: Bad character constant
-escapes.c:6:38: error: Bad character constant
-escapes.c:6:42: error: Bad character constant
-escapes.c:6:46: error: Bad character constant
-escapes.c:6:53: error: Bad character constant
-escapes.c:6:56: error: Bad character constant
-escapes.c:6:42: error: Expected } at end of initializer
-escapes.c:6:42: error: got 89
+escapes.c:6:26: warning: Unknown escape 'c'
+escapes.c:3:34: warning: hex escape sequence out of range
+escapes.c:3:44: warning: hex escape sequence out of range
+escapes.c:4:18: warning: hex escape sequence out of range
+escapes.c:6:30: warning: multi-character character constant
+escapes.c:6:39: warning: multi-character character constant
+escapes.c:6:47: warning: hex escape sequence out of range
+escapes.c:6:47: warning: multi-character character constant
* check-error-end
*/
diff --git a/validation/preprocessor/stringify.c b/validation/preprocessor/stringify.c
new file mode 100644
index 00000000..7fe965d5
--- /dev/null
+++ b/validation/preprocessor/stringify.c
@@ -0,0 +1,29 @@
+#define A(x) #x
+A('a')
+A("a")
+A(a)
+A(\n)
+A('\n')
+A("\n")
+A('"')
+A("a\nb")
+A(L"a\nb")
+A('\12')
+/*
+ * check-name: Preprocessor #14
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+"'a'"
+"\"a\""
+"a"
+"\n"
+"'\\n'"
+"\"\\n\""
+"'\"'"
+"\"a\\nb\""
+"L\"a\\nb\""
+"'\\12'"
+ * check-output-end
+ */