extra: small fix for when the database is disabled but we have inline info
[smatch.git] / validation / phase2 / backslash
blob29c85b4d0fcd17bcdbac8d3fa60f283158094f1d
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.
5  *
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.
14  *
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.
18  */
20 #define A(x) #x
21 #define B(x) A(x)
22 /* This should result in "\a" */
23 /* XXX: currently sparse produces "a" */
24 /* Partially fixed: now it gives "\\a", which is a separate problem */
25 B(\a)
27 #define C\
28  1
29 /* This should give 1 */
32 #define D\
34 /* And this should give D, since '\n' is removed and we get no whitespace */
35 /* XXX: currently sparse produces 1 */
36 /* Fixed */
39 #define E '\\
41 /* This should give '\a' - with no warnings issued */
42 /* XXX: currently sparse complains a lot and ends up producing a */
43 /* Fixed */
46 /* This should give nothing */
47 /* XXX: currently sparse produces more junk */
48 /* Fixed */
49 // junk \
50 more junk
52 /* This should also give nothing */
53 /* XXX: currently sparse produces / * comment * / */
54 /* Fixed */
56 * comment *\
59 /* And this should complain since final newline should not be eaten by '\\' */
60 /* XXX: currently sparse does not notice */
61 /* Fixed */