aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-09-10 22:27:29 +0000
committerDouglas Gregor <dgregor@apple.com>2010-09-10 22:27:29 +0000
commitfe6834af25d0809215c9e205c9983dd6d3f968b4 (patch)
tree206c45a0252c0b2596712990fc7d9b730f16e71e
parentbd7c849de9a1647b235597681c3983ba1e8c6c8b (diff)
Make sure we're producing a newline in the preprocessed output before
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
-rw-r--r--lib/Frontend/PrintPreprocessedOutput.cpp3
-rw-r--r--test/Lexer/pragma-operators.cpp15
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp
index 2159d3e80d..d0aef2918c 100644
--- a/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -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();
diff --git a/test/Lexer/pragma-operators.cpp b/test/Lexer/pragma-operators.cpp
index af346e8c96..d1645adbc2 100644
--- a/test/Lexer/pragma-operators.cpp
+++ b/test/Lexer/pragma-operators.cpp
@@ -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)