Print this page
11972 resync smatch
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/validation/phase2/backslash
+++ new/usr/src/tools/smatch/src/validation/preprocessor/phase2-backslash.c
1 1 /*
2 2 * '\\' has a special meaning on phase 2 if and only if it is immediately
3 3 * followed by '\n'. In any other position it's left alone as any other
4 4 * character.
5 5 *
6 6 * [5.1.1.2(1.2)]:
7 7 * Each instance of a backslash character (\) immediately followed by
8 8 * a new-line character is deleted, splicing physical source lines to
9 9 * form logical source lines. Only the last backslash on any physical
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
10 10 * source line shall be eligible for being part of such a splice.
11 11 * A source file that is not empty shall end in a new-line character,
12 12 * which shall not be immediately preceded by a backslash character
13 13 * before any such splicing takes place.
14 14 *
15 15 * Note that this happens on the phase 2, before we even think of any
16 16 * tokens. In other words, splicing is ignorant of and transparent for
17 17 * the rest of tokenizer.
18 18 */
19 19
20 +/*
21 + * check-name: phase2-backslash
22 + * check-command: sparse -E $file
23 + *
24 + * check-output-start
25 +
26 +"\a"
27 +1
28 +D
29 +'\a'
30 + * check-output-end
31 + *
32 + * check-error-start
33 +preprocessor/phase2-backslash.c:68:0: warning: backslash-newline at end of file
34 + * check-error-end
35 + */
36 +
20 37 #define A(x) #x
21 38 #define B(x) A(x)
22 39 /* This should result in "\a" */
23 -/* XXX: currently sparse produces "a" */
24 -/* Partially fixed: now it gives "\\a", which is a separate problem */
25 40 B(\a)
26 41
27 42 #define C\
28 43 1
29 44 /* This should give 1 */
30 45 C
31 46
32 47 #define D\
33 48 1
34 49 /* And this should give D, since '\n' is removed and we get no whitespace */
35 -/* XXX: currently sparse produces 1 */
36 -/* Fixed */
37 50 D
38 51
39 52 #define E '\\
40 53 a'
41 54 /* This should give '\a' - with no warnings issued */
42 -/* XXX: currently sparse complains a lot and ends up producing a */
43 -/* Fixed */
44 55 E
45 56
46 57 /* This should give nothing */
47 -/* XXX: currently sparse produces more junk */
48 -/* Fixed */
49 58 // junk \
50 59 more junk
51 60
52 61 /* This should also give nothing */
53 -/* XXX: currently sparse produces / * comment * / */
54 -/* Fixed */
55 62 /\
56 63 * comment *\
57 64 /
58 65
59 66 /* And this should complain since final newline should not be eaten by '\\' */
60 -/* XXX: currently sparse does not notice */
61 -/* Fixed */
62 67 \
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX