diff options
-rw-r--r-- | Lex/Preprocessor.cpp | 4 | ||||
-rw-r--r-- | test/Preprocessor/ifdef-recover.c | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp index cb5a350758..d831093268 100644 --- a/Lex/Preprocessor.cpp +++ b/Lex/Preprocessor.cpp @@ -939,9 +939,9 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, // an argument value in a macro could expand to ',' or '(' or ')'. LexUnexpandedToken(Tok); - if (Tok.is(tok::eof)) { + if (Tok.is(tok::eof) || Tok.is(tok::eom)) { // "#if f(<eof>" & "#if f(\n" Diag(MacroName, diag::err_unterm_macro_invoc); - // Do not lose the EOF. Return it to the client. + // Do not lose the EOF/EOM. Return it to the client. MacroName = Tok; return 0; } else if (Tok.is(tok::r_paren)) { diff --git a/test/Preprocessor/ifdef-recover.c b/test/Preprocessor/ifdef-recover.c index 2009514f5e..bd1d507bbc 100644 --- a/test/Preprocessor/ifdef-recover.c +++ b/test/Preprocessor/ifdef-recover.c @@ -1,7 +1,15 @@ -/* RUN: clang %s 2>&1 | grep error: | count 1 +/* RUN: clang %s 2>&1 | grep error: | count 3 */ #ifdef #endif +/* End of function-like macro invocation in #ifdef */ +/* PR1936 */ +#define f(x) x +#if f(2 +#endif + +int x; + |