Daniel Dunbar | 2ed4228 | 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 | 6aad4a3 | 2013-02-21 18:53:19 +0000 | [diff] [blame] | 7 | RUN: FileCheck -strict-whitespace < %t %s |
Jordan Rose | cf2c2e9 | 2013-03-05 23:54:55 +0000 | [diff] [blame] | 8 | RUN: %clang_cc1 -traditional-cpp %s -E -C | FileCheck -check-prefix=CHECK-COMMENTS %s |
Daniel Dunbar | 2ed4228 | 2011-03-18 21:23:38 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Jordan Rose | cf2c2e9 | 2013-03-05 23:54:55 +0000 | [diff] [blame] | 11 | /* -traditional-cpp should eliminate all C89 comments. */ |
| 12 | /* CHECK-NOT: /* |
| 13 | * CHECK-COMMENTS: {{^}}/* -traditional-cpp should eliminate all C89 comments. *{{/$}} |
| 14 | */ |
| 15 | |
Jordan Rose | 6aad4a3 | 2013-02-21 18:53:19 +0000 | [diff] [blame] | 16 | /* CHECK: {{^}}foo // bar{{$}} |
Daniel Dunbar | 2ed4228 | 2011-03-18 21:23:38 +0000 | [diff] [blame] | 17 | */ |
| 18 | foo // bar |
Jordan Rose | 6aad4a3 | 2013-02-21 18:53:19 +0000 | [diff] [blame] | 19 | |
| 20 | |
| 21 | /* The lines in this file contain hard tab characters and trailing whitespace; |
| 22 | * do not change them! */ |
| 23 | |
| 24 | /* CHECK: {{^}} indented!{{$}} |
| 25 | * CHECK: {{^}}tab separated values{{$}} |
| 26 | */ |
| 27 | indented! |
| 28 | tab separated values |
| 29 | |
| 30 | #define bracket(x) >>>x<<< |
| 31 | bracket(| spaces |) |
| 32 | /* CHECK: {{^}}>>>| spaces |<<<{{$}} |
| 33 | */ |
| 34 | |
| 35 | /* This is still a preprocessing directive. */ |
| 36 | # define foo bar |
| 37 | foo! |
| 38 | - |
| 39 | foo! foo! |
| 40 | /* CHECK: {{^}}bar!{{$}} |
| 41 | * CHECK: {{^}} bar! bar! {{$}} |
| 42 | */ |
| 43 | |
| 44 | /* Deliberately check a leading newline with spaces on that line. */ |
| 45 | |
| 46 | # define foo bar |
| 47 | foo! |
| 48 | - |
| 49 | foo! foo! |
| 50 | /* CHECK: {{^}}bar!{{$}} |
| 51 | * CHECK: {{^}} bar! bar! {{$}} |
| 52 | */ |
| 53 | |
| 54 | /* FIXME: -traditional-cpp should not consider this a preprocessing directive |
| 55 | * because the # isn't in the first column. |
| 56 | */ |
| 57 | #define foo2 bar |
| 58 | foo2! |
| 59 | /* If this were working, both of these checks would be on. |
| 60 | * CHECK-NOT: {{^}} #define foo2 bar{{$}} |
| 61 | * CHECK-NOT: {{^}}foo2!{{$}} |
| 62 | */ |
| 63 | |
| 64 | /* FIXME: -traditional-cpp should not homogenize whitespace in macros. |
| 65 | */ |
| 66 | #define bracket2(x) >>> x <<< |
| 67 | bracket2(spaces) |
| 68 | /* If this were working, this check would be on. |
| 69 | * CHECK-NOT: {{^}}>>> spaces <<<{{$}} |
| 70 | */ |
Jordan Rose | c7d1ca5 | 2013-02-22 00:32:00 +0000 | [diff] [blame] | 71 | |
| 72 | |
| 73 | /* Check that #if 0 blocks work as expected */ |
| 74 | #if 0 |
| 75 | #error "this is not an error" |
| 76 | |
| 77 | #if 1 |
| 78 | a b c in skipped block |
| 79 | #endif |
| 80 | |
| 81 | /* Comments are whitespace too */ |
| 82 | |
| 83 | #endif |
| 84 | /* CHECK-NOT: {{^}}a b c in skipped block{{$}} |
| 85 | * CHECK-NOT: {{^}}/* Comments are whitespace too |
| 86 | */ |
Jordan Rose | 693fdfa | 2013-03-05 22:51:04 +0000 | [diff] [blame] | 87 | |
| 88 | Preserve URLs: http://clang.llvm.org |
| 89 | /* CHECK: {{^}}Preserve URLs: http://clang.llvm.org{{$}} |
| 90 | */ |