fix rdar://6816766 - Crash with function-like macro test at end of directive.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69964 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 4d6450b..fff6f10 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -1276,6 +1276,7 @@
// Save state that can be changed while lexing so that we can restore it.
const char *TmpBufferPtr = BufferPtr;
+ bool inPPDirectiveMode = ParsingPreprocessorDirective;
Token Tok;
Tok.startToken();
@@ -1283,6 +1284,7 @@
// Restore state that may have changed.
BufferPtr = TmpBufferPtr;
+ ParsingPreprocessorDirective = inPPDirectiveMode;
// Restore the lexer back to non-skipping mode.
LexingRawMode = false;
diff --git a/test/Preprocessor/macro_fn.c b/test/Preprocessor/macro_fn.c
index 98ebaee..5c55c0c 100644
--- a/test/Preprocessor/macro_fn.c
+++ b/test/Preprocessor/macro_fn.c
@@ -38,3 +38,9 @@
zero_dot()
one_dot(x) /* empty ... argument: expected-warning {{varargs argument missing, but tolerated as an extension}} */
one_dot() /* empty first argument, elided ...: expected-warning {{varargs argument missing, but tolerated as an extension}} */
+
+
+/* rdar://6816766 - Crash with function-like macro test at end of directive. */
+#define E() (i == 0)
+#if E
+#endif