[cfe-commits] r113648 - in /cfe/trunk: lib/Frontend/PrintPreprocessedOutput.cpp test/Lexer/pragma-operators.cpp

Douglas Gregor dgregor at apple.com
Fri Sep 10 15:27:29 PDT 2010


Author: dgregor
Date: Fri Sep 10 17:27:29 2010
New Revision: 113648

URL: http://llvm.org/viewvc/llvm-project?rev=113648&view=rev
Log:
Make sure we're producing a newline in the preprocessed output before
emitting a #pragma, whenever one is needed. Fixes <rdar://problem/8417307>.


Modified:
    cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
    cfe/trunk/test/Lexer/pragma-operators.cpp

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=113648&r1=113647&r2=113648&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Fri Sep 10 17:27:29 2010
@@ -455,8 +455,7 @@
                             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();

Modified: cfe/trunk/test/Lexer/pragma-operators.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/pragma-operators.cpp?rev=113648&r1=113647&r2=113648&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/pragma-operators.cpp (original)
+++ cfe/trunk/test/Lexer/pragma-operators.cpp Fri Sep 10 17:27:29 2010
@@ -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)





More information about the cfe-commits mailing list