brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · f311be0 Raw
110 lines · c
1/* Clang supports a very limited subset of -traditional-cpp, basically we only2 * intend to add support for things that people actually rely on when doing3 * things like using /usr/bin/cpp to preprocess non-source files. */4 5/*6 RUN: %clang_cc1 -traditional-cpp %s -E | FileCheck -strict-whitespace %s7 RUN: %clang_cc1 -traditional-cpp %s -E -C | FileCheck -check-prefix=CHECK-COMMENTS %s8 RUN: %clang_cc1 -traditional-cpp -x c++ %s -E | FileCheck -check-prefix=CHECK-CXX %s9*/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 */20foo // bar21 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!30tab	separated	values31 32#define bracket(x) >>>x<<<33bracket(|  spaces  |)34/* CHECK: {{^}}>>>|  spaces  |<<<{{$}}35 */36 37/* This is still a preprocessing directive. */38# define foo bar39foo!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 bar49foo!50-51	foo!	foo!	52/* CHECK: {{^}}bar!{{$}}53 * CHECK: {{^}}	bar!	bar!	{{$}}54 */55 56/* FIXME: -traditional-cpp should not consider this a preprocessing directive57 * because the # isn't in the first column.58 */59 #define foo2 bar60foo2!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  <<<69bracket2(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 077#error "this is not an error"78 79#if 180a b c in skipped block81#endif82 83/* Comments are whitespace too */84 85#endif86/* CHECK-NOT: {{^}}a b c in skipped block{{$}}87 * CHECK-NOT: {{^}}/* Comments are whitespace too88 */89 90Preserve URLs: http://clang.llvm.org91/* 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)97FOO_NO_STRINGIFY(foobar)98/* CHECK: {{^}}test(# foobar){{$}}99 */100 101#define FOO_NO_PASTE(a, b) test(b##a)102FOO_NO_PASTE(xxx,yyy)103/* CHECK: {{^}}test(yyy##xxx){{$}}104 */105 106#define BAR_NO_STRINGIFY(a) test(#a)107BAR_NO_STRINGIFY(foobar)108/* CHECK: {{^}}test(#foobar){{$}}109 */110