states: rename unreachable() to is_unreachable()
[smatch.git] / validation / preprocessor / phase2-backslash.c
blob21d94d7dc8526e398f634120a0a0201e39cd1d45
1 /*
2 * '\\' has a special meaning on phase 2 if and only if it is immediately
3 * followed by '\n'. In any other position it's left alone as any other
4 * character.
6 * [5.1.1.2(1.2)]:
7 * Each instance of a backslash character (\) immediately followed by
8 * a new-line character is deleted, splicing physical source lines to
9 * form logical source lines. Only the last backslash on any physical
10 * source line shall be eligible for being part of such a splice.
11 * A source file that is not empty shall end in a new-line character,
12 * which shall not be immediately preceded by a backslash character
13 * before any such splicing takes place.
15 * Note that this happens on the phase 2, before we even think of any
16 * tokens. In other words, splicing is ignorant of and transparent for
17 * the rest of tokenizer.
21 * check-name: phase2-backslash
22 * check-command: sparse -E $file
24 * check-output-start
26 "\a"
29 '\a'
30 * check-output-end
32 * check-error-start
33 preprocessor/phase2-backslash.c:68:0: warning: backslash-newline at end of file
34 * check-error-end
37 #define A(x) #x
38 #define B(x) A(x)
39 /* This should result in "\a" */
40 B(\a)
42 #define C\
44 /* This should give 1 */
47 #define D\
49 /* And this should give D, since '\n' is removed and we get no whitespace */
52 #define E '\\
54 /* This should give '\a' - with no warnings issued */
57 /* This should give nothing */
58 // junk \
59 more junk
61 /* This should also give nothing */
63 * comment *\
66 /* And this should complain since final newline should not be eaten by '\\' */