From: Chris Lattner Date: Fri, 24 Apr 2009 07:15:46 +0000 (+0000) Subject: fix rdar://6816766 - Crash with function-like macro test at end of directive. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a864cf7c1d774a0f790bfc46befc87d9dbf1f65c;p=clang 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 4d6450b914..fff6f10fa9 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -1276,6 +1276,7 @@ unsigned Lexer::isNextPPTokenLParen() { // 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 @@ unsigned Lexer::isNextPPTokenLParen() { // 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 98ebaeea72..5c55c0ceed 100644 --- a/test/Preprocessor/macro_fn.c +++ b/test/Preprocessor/macro_fn.c @@ -38,3 +38,9 @@ e() 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