summaryrefslogtreecommitdiff
path: root/test/Preprocessor/traditional-cpp.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Preprocessor/traditional-cpp.c')
-rw-r--r--test/Preprocessor/traditional-cpp.c82
1 files changed, 80 insertions, 2 deletions
diff --git a/test/Preprocessor/traditional-cpp.c b/test/Preprocessor/traditional-cpp.c
index 5fc9ee398ecf..4c4633e03920 100644
--- a/test/Preprocessor/traditional-cpp.c
+++ b/test/Preprocessor/traditional-cpp.c
@@ -4,9 +4,87 @@
/*
RUN: %clang_cc1 -traditional-cpp %s -E -o %t
- RUN: FileCheck < %t %s
+ RUN: FileCheck -strict-whitespace < %t %s
+ RUN: %clang_cc1 -traditional-cpp %s -E -C | FileCheck -check-prefix=CHECK-COMMENTS %s
*/
-/* CHECK: foo // bar
+/* -traditional-cpp should eliminate all C89 comments. */
+/* CHECK-NOT: /*
+ * CHECK-COMMENTS: {{^}}/* -traditional-cpp should eliminate all C89 comments. *{{/$}}
+ */
+
+/* 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 <<<{{$}}
+ */
+
+
+/* Check that #if 0 blocks work as expected */
+#if 0
+#error "this is not an error"
+
+#if 1
+a b c in skipped block
+#endif
+
+/* Comments are whitespace too */
+
+#endif
+/* CHECK-NOT: {{^}}a b c in skipped block{{$}}
+ * CHECK-NOT: {{^}}/* Comments are whitespace too
+ */
+
+Preserve URLs: http://clang.llvm.org
+/* CHECK: {{^}}Preserve URLs: http://clang.llvm.org{{$}}
+ */