]> granicus.if.org Git - clang/commitdiff
Make sure we're producing a newline in the preprocessed output before
authorDouglas Gregor <dgregor@apple.com>
Fri, 10 Sep 2010 22:27:29 +0000 (22:27 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 10 Sep 2010 22:27:29 +0000 (22:27 +0000)
emitting a #pragma, whenever one is needed. Fixes <rdar://problem/8417307>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113648 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PrintPreprocessedOutput.cpp
test/Lexer/pragma-operators.cpp

index 2159d3e80d889d949af95f3c5bbbf867b1a61c8f..d0aef2918cc1a199e3f146b1ca7b053758494969 100644 (file)
@@ -455,8 +455,7 @@ struct UnknownPragmaHandler : public PragmaHandler {
                             Token &PragmaTok) {
     // Figure out what line we went to and insert the appropriate number of
     // newline characters.
-    if (Introducer == PIK__Pragma || Introducer == PIK___pragma)
-      Callbacks->StartNewLineIfNeeded();
+    Callbacks->StartNewLineIfNeeded();
     Callbacks->MoveToLine(PragmaTok.getLocation());
     Callbacks->OS.write(Prefix, strlen(Prefix));
     Callbacks->SetEmittedTokensOnThisLine();
index af346e8c968686920248ca22ef735e3d229accd4..d1645adbc252970d29be26dd013a9e250ed42b29 100644 (file)
@@ -3,13 +3,18 @@
 // Test that we properly expand the C99 _Pragma and Microsoft __pragma
 // into #pragma directives, with newlines where needed. <rdar://problem/8412013>
 
-// CHECK: extern
 // CHECK: #line
 // CHECK: #pragma warning(push)
+// CHECK: extern "C" {
 // CHECK: #line
-// CHECK: ; void f0();
+// CHECK: #pragma warning(push)
+// CHECK:  int foo() { return 0; } }
 // CHECK: #line
 // CHECK: #pragma warning(pop)
-// CHECK: #line
-// CHECK: ; }
-extern "C" { _Pragma("warning(push)"); void f0(); __pragma(warning(pop)); }
+#define A(X) extern "C" { __pragma(warning(push)) \
+  int X() { return 0; } \
+}
+#define B(X) A(X)
+#pragma warning(push)
+B(foo)
+#pragma warning(pop)