Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Preprocessor / traditional-cpp.c
blobf311be0bb593600fde748d6ea00de267d3feee0f
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. */
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 */
11 /* -traditional-cpp should eliminate all C89 comments. */
12 /* CHECK-NOT: /*
13 * CHECK-COMMENTS: {{^}}/* -traditional-cpp should eliminate all C89 comments. *{{/$}}
16 /* -traditional-cpp should only eliminate "//" comments in C++ mode. */
17 /* CHECK: {{^}}foo // bar{{$}}
18 * CHECK-CXX: {{^}}foo {{$}}
20 foo // bar
23 /* The lines in this file contain hard tab characters and trailing whitespace;
24 * do not change them! */
26 /* CHECK: {{^}} indented!{{$}}
27 * CHECK: {{^}}tab separated values{{$}}
29 indented!
30 tab separated values
32 #define bracket(x) >>>x<<<
33 bracket(| spaces |)
34 /* CHECK: {{^}}>>>| spaces |<<<{{$}}
37 /* This is still a preprocessing directive. */
38 # define foo bar
39 foo!
41 foo! foo!
42 /* CHECK: {{^}}bar!{{$}}
43 * CHECK: {{^}} bar! bar! {{$}}
46 /* Deliberately check a leading newline with spaces on that line. */
48 # define foo bar
49 foo!
51 foo! foo!
52 /* CHECK: {{^}}bar!{{$}}
53 * CHECK: {{^}} bar! bar! {{$}}
56 /* FIXME: -traditional-cpp should not consider this a preprocessing directive
57 * because the # isn't in the first column.
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!{{$}}
66 /* FIXME: -traditional-cpp should not homogenize whitespace in macros.
68 #define bracket2(x) >>> x <<<
69 bracket2(spaces)
70 /* If this were working, this check would be on.
71 * CHECK-NOT: {{^}}>>> spaces <<<{{$}}
75 /* Check that #if 0 blocks work as expected */
76 #if 0
77 #error "this is not an error"
79 #if 1
80 a b c in skipped block
81 #endif
83 /* Comments are whitespace too */
85 #endif
86 /* CHECK-NOT: {{^}}a b c in skipped block{{$}}
87 * CHECK-NOT: {{^}}/* Comments are whitespace too
90 Preserve URLs: http://clang.llvm.org
91 /* CHECK: {{^}}Preserve URLs: http://clang.llvm.org{{$}}
94 /* The following tests ensure we ignore # and ## in macro bodies */
96 #define FOO_NO_STRINGIFY(a) test(# a)
97 FOO_NO_STRINGIFY(foobar)
98 /* CHECK: {{^}}test(# foobar){{$}}
101 #define FOO_NO_PASTE(a, b) test(b##a)
102 FOO_NO_PASTE(xxx,yyy)
103 /* CHECK: {{^}}test(yyy##xxx){{$}}
106 #define BAR_NO_STRINGIFY(a) test(#a)
107 BAR_NO_STRINGIFY(foobar)
108 /* CHECK: {{^}}test(#foobar){{$}}