Daniel Dunbar | 1057f86 | 2011-03-18 21:23:38 +0000 | [diff] [blame] | 1 | /* 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 Rose | cb8a1ac | 2013-02-21 18:53:19 +0000 | [diff] [blame] | 7 | RUN: FileCheck -strict-whitespace < %t %s |
Daniel Dunbar | 1057f86 | 2011-03-18 21:23:38 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
Jordan Rose | cb8a1ac | 2013-02-21 18:53:19 +0000 | [diff] [blame] | 10 | /* CHECK: {{^}}foo // bar{{$}} |
Daniel Dunbar | 1057f86 | 2011-03-18 21:23:38 +0000 | [diff] [blame] | 11 | */ |
| 12 | foo // bar |
Jordan Rose | cb8a1ac | 2013-02-21 18:53:19 +0000 | [diff] [blame] | 13 | |
| 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! |
| 22 | tab separated values |
| 23 | |
| 24 | #define bracket(x) >>>x<<< |
| 25 | bracket(| spaces |) |
| 26 | /* CHECK: {{^}}>>>| spaces |<<<{{$}} |
| 27 | */ |
| 28 | |
| 29 | /* This is still a preprocessing directive. */ |
| 30 | # define foo bar |
| 31 | foo! |
| 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 |
| 41 | foo! |
| 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 |
| 52 | foo2! |
| 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 <<< |
| 61 | bracket2(spaces) |
| 62 | /* If this were working, this check would be on. |
| 63 | * CHECK-NOT: {{^}}>>> spaces <<<{{$}} |
| 64 | */ |
Jordan Rose | 176057b | 2013-02-22 00:32:00 +0000 | [diff] [blame^] | 65 | |
| 66 | |
| 67 | /* Check that #if 0 blocks work as expected */ |
| 68 | #if 0 |
| 69 | #error "this is not an error" |
| 70 | |
| 71 | #if 1 |
| 72 | a 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 | */ |