| 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 | FileCheck -strict-whitespace %s |
| 7 |
RUN: %clang_cc1 -traditional-cpp %s -E -C | FileCheck -check-prefix=CHECK-COMMENTS %s |
| 8 |
RUN: %clang_cc1 -traditional-cpp -x c++ %s -E | FileCheck -check-prefix=CHECK-CXX %s |
| 9 |
*/ |
| 10 |
|
| 11 |
/* -traditional-cpp should eliminate all C89 comments. */ |
| 12 |
/* CHECK-NOT: /* |
| 13 |
* CHECK-COMMENTS: {{^}}/* -traditional-cpp should eliminate all C89 comments. *{{/$}} |
| 14 |
*/ |
| 15 |
|
| 16 |
/* -traditional-cpp should only eliminate "//" comments in C++ mode. */ |
| 17 |
/* CHECK: {{^}}foo // bar{{$}} |
| 18 |
* CHECK-CXX: {{^}}foo {{$}} |
| 19 |
*/ |
| 20 |
foo // bar |
| 21 |
|
| 22 |
|
| 23 |
/* The lines in this file contain hard tab characters and trailing whitespace; |
| 24 |
* do not change them! */ |
| 25 |
|
| 26 |
/* CHECK: {{^}} indented!{{$}} |
| 27 |
* CHECK: {{^}}tab separated values{{$}} |
| 28 |
*/ |
| 29 |
indented! |
| 30 |
tab separated values |
| 31 |
|
| 32 |
#define bracket(x) >>>x<<< |
| 33 |
bracket(| spaces |) |
| 34 |
/* CHECK: {{^}}>>>| spaces |<<<{{$}} |
| 35 |
*/ |
| 36 |
|
| 37 |
/* This is still a preprocessing directive. */ |
| 38 |
# define foo bar |
| 39 |
foo! |
| 40 |
- |
| 41 |
foo! foo! |
| 42 |
/* CHECK: {{^}}bar!{{$}} |
| 43 |
* CHECK: {{^}} bar! bar! {{$}} |
| 44 |
*/ |
| 45 |
|
| 46 |
/* Deliberately check a leading newline with spaces on that line. */ |
| 47 |
|
| 48 |
# define foo bar |
| 49 |
foo! |
| 50 |
- |
| 51 |
foo! foo! |
| 52 |
/* CHECK: {{^}}bar!{{$}} |
| 53 |
* CHECK: {{^}} bar! bar! {{$}} |
| 54 |
*/ |
| 55 |
|
| 56 |
/* FIXME: -traditional-cpp should not consider this a preprocessing directive |
| 57 |
* because the # isn't in the first column. |
| 58 |
*/ |
| 59 |
#define foo2 bar |
| 60 |
foo2! |
| 61 |
/* If this were working, both of these checks would be on. |
| 62 |
* CHECK-NOT: {{^}} #define foo2 bar{{$}} |
| 63 |
* CHECK-NOT: {{^}}foo2!{{$}} |
| 64 |
*/ |
| 65 |
|
| 66 |
/* FIXME: -traditional-cpp should not homogenize whitespace in macros. |
| 67 |
*/ |
| 68 |
#define bracket2(x) >>> x <<< |
| 69 |
bracket2(spaces) |
| 70 |
/* If this were working, this check would be on. |
| 71 |
* CHECK-NOT: {{^}}>>> spaces <<<{{$}} |
| 72 |
*/ |
| 73 |
|
| 74 |
|
| 75 |
/* Check that #if 0 blocks work as expected */ |
| 76 |
#if 0 |
| 77 |
#error "this is not an error" |
| 78 |
|
| 79 |
#if 1 |
| 80 |
a b c in skipped block |
| 81 |
#endif |
| 82 |
|
| 83 |
/* Comments are whitespace too */ |
| 84 |
|
| 85 |
#endif |
| 86 |
/* CHECK-NOT: {{^}}a b c in skipped block{{$}} |
| 87 |
* CHECK-NOT: {{^}}/* Comments are whitespace too |
| 88 |
*/ |
| 89 |
|
| 90 |
Preserve URLs: http://clang.llvm.org |
| 91 |
/* CHECK: {{^}}Preserve URLs: http://clang.llvm.org{{$}} |
| 92 |
*/ |
| 93 |
|
| 94 |
/* The following tests ensure we ignore # and ## in macro bodies */ |
| 95 |
|
| 96 |
#define FOO_NO_STRINGIFY(a) test(# a) |
| 97 |
FOO_NO_STRINGIFY(foobar) |
| 98 |
/* CHECK: {{^}}test(# foobar){{$}} |
| 99 |
*/ |
| 100 |
|
| 101 |
#define FOO_NO_PASTE(a, b) test(b##a) |
| 102 |
FOO_NO_PASTE(xxx,yyy) |
| 103 |
/* CHECK: {{^}}test(yyy##xxx){{$}} |
| 104 |
*/ |
| 105 |
|
| 106 |
#define BAR_NO_STRINGIFY(a) test(#a) |
| 107 |
BAR_NO_STRINGIFY(foobar) |
| 108 |
/* CHECK: {{^}}test(#foobar){{$}} |
| 109 |
*/ |