blob: 5a94c00c969fb969ed611f580e905c3bcbc3e72a [file] [log] [blame]
Daniel Dunbar1057f862011-03-18 21:23:38 +00001/* Clang supports a very limited subset of -traditional-cpp, basically we only
2 * intend to add support for things that people actually rely on when doing
3 * things like using /usr/bin/cpp to preprocess non-source files. */
4
5/*
6 RUN: %clang_cc1 -traditional-cpp %s -E -o %t
Jordan Rosecb8a1ac2013-02-21 18:53:19 +00007 RUN: FileCheck -strict-whitespace < %t %s
Daniel Dunbar1057f862011-03-18 21:23:38 +00008*/
9
Jordan Rosecb8a1ac2013-02-21 18:53:19 +000010/* CHECK: {{^}}foo // bar{{$}}
Daniel Dunbar1057f862011-03-18 21:23:38 +000011 */
12foo // bar
Jordan Rosecb8a1ac2013-02-21 18:53:19 +000013
14
15/* The lines in this file contain hard tab characters and trailing whitespace;
16 * do not change them! */
17
18/* CHECK: {{^}} indented!{{$}}
19 * CHECK: {{^}}tab separated values{{$}}
20 */
21 indented!
22tab separated values
23
24#define bracket(x) >>>x<<<
25bracket(| spaces |)
26/* CHECK: {{^}}>>>| spaces |<<<{{$}}
27 */
28
29/* This is still a preprocessing directive. */
30# define foo bar
31foo!
32-
33 foo! foo!
34/* CHECK: {{^}}bar!{{$}}
35 * CHECK: {{^}} bar! bar! {{$}}
36 */
37
38/* Deliberately check a leading newline with spaces on that line. */
39
40# define foo bar
41foo!
42-
43 foo! foo!
44/* CHECK: {{^}}bar!{{$}}
45 * CHECK: {{^}} bar! bar! {{$}}
46 */
47
48/* FIXME: -traditional-cpp should not consider this a preprocessing directive
49 * because the # isn't in the first column.
50 */
51 #define foo2 bar
52foo2!
53/* If this were working, both of these checks would be on.
54 * CHECK-NOT: {{^}} #define foo2 bar{{$}}
55 * CHECK-NOT: {{^}}foo2!{{$}}
56 */
57
58/* FIXME: -traditional-cpp should not homogenize whitespace in macros.
59 */
60#define bracket2(x) >>> x <<<
61bracket2(spaces)
62/* If this were working, this check would be on.
63 * CHECK-NOT: {{^}}>>> spaces <<<{{$}}
64 */
Jordan Rose176057b2013-02-22 00:32:00 +000065
66
67/* Check that #if 0 blocks work as expected */
68#if 0
69#error "this is not an error"
70
71#if 1
72a b c in skipped block
73#endif
74
75/* Comments are whitespace too */
76
77#endif
78/* CHECK-NOT: {{^}}a b c in skipped block{{$}}
79 * CHECK-NOT: {{^}}/* Comments are whitespace too
80 */