From cb8a1aca35ecc33a5adcc0892aa31fb2a7750dc8 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Thu, 21 Feb 2013 18:53:19 +0000 Subject: Preprocessor: preserve whitespace in -traditional-cpp mode. Note that unlike GNU cpp we currently do not preserve whitespace in macros (even in -traditional-cpp mode). llvm-svn: 175778 --- clang/test/Preprocessor/traditional-cpp.c | 56 +++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'clang/test/Preprocessor/traditional-cpp.c') diff --git a/clang/test/Preprocessor/traditional-cpp.c b/clang/test/Preprocessor/traditional-cpp.c index 5fc9ee398ec..72024546ff3 100644 --- a/clang/test/Preprocessor/traditional-cpp.c +++ b/clang/test/Preprocessor/traditional-cpp.c @@ -4,9 +4,61 @@ /* RUN: %clang_cc1 -traditional-cpp %s -E -o %t - RUN: FileCheck < %t %s + RUN: FileCheck -strict-whitespace < %t %s */ -/* CHECK: foo // bar +/* CHECK: {{^}}foo // bar{{$}} */ foo // bar + + +/* The lines in this file contain hard tab characters and trailing whitespace; + * do not change them! */ + +/* CHECK: {{^}} indented!{{$}} + * CHECK: {{^}}tab separated values{{$}} + */ + indented! +tab separated values + +#define bracket(x) >>>x<<< +bracket(| spaces |) +/* CHECK: {{^}}>>>| spaces |<<<{{$}} + */ + +/* This is still a preprocessing directive. */ +# define foo bar +foo! +- + foo! foo! +/* CHECK: {{^}}bar!{{$}} + * CHECK: {{^}} bar! bar! {{$}} + */ + +/* Deliberately check a leading newline with spaces on that line. */ + +# define foo bar +foo! +- + foo! foo! +/* CHECK: {{^}}bar!{{$}} + * CHECK: {{^}} bar! bar! {{$}} + */ + +/* FIXME: -traditional-cpp should not consider this a preprocessing directive + * because the # isn't in the first column. + */ + #define foo2 bar +foo2! +/* If this were working, both of these checks would be on. + * CHECK-NOT: {{^}} #define foo2 bar{{$}} + * CHECK-NOT: {{^}}foo2!{{$}} + */ + +/* FIXME: -traditional-cpp should not homogenize whitespace in macros. + */ +#define bracket2(x) >>> x <<< +bracket2(spaces) +/* If this were working, this check would be on. + * CHECK-NOT: {{^}}>>> spaces <<<{{$}} + */ -- cgit v1.2.3