diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index a58c935620..c57a736d1b 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -573,6 +573,15 @@ struct UnknownPragmaHandler : public PragmaHandler { Token &PragmaTok) override { // Figure out what line we went to and insert the appropriate number of // newline characters. + if (ShouldExpandTokens) { + // The first token does not have expanded macros. Expand them, if + // required. + Token Toks[] = {PragmaTok}; + PP.EnterTokenStream(Toks, llvm::array_lengthof(Toks), + /*DisableMacroExpansion=*/false, + /*OwnsTokens=*/false); + PP.Lex(PragmaTok); + } Callbacks->startNewLineIfNeeded(); Callbacks->MoveToLine(PragmaTok.getLocation()); Callbacks->OS.write(Prefix, strlen(Prefix)); diff --git a/test/Preprocessor/macro_expand.c b/test/Preprocessor/macro_expand.c index cf98a2cbfb..430068ba72 100644 --- a/test/Preprocessor/macro_expand.c +++ b/test/Preprocessor/macro_expand.c @@ -19,3 +19,9 @@ C: for(for)) // rdar://6880648 #define f(x,y...) y f() + +// CHECK: #pragma omp parallel for +#define FOO parallel +#define Streaming _Pragma("omp FOO for") +Streaming +