[cfe-commits] r46256 - in /cfe/trunk: Lex/Preprocessor.cpp test/Preprocessor/ifdef-recover.c
Chris Lattner
sabre at nondot.org
Tue Jan 22 11:34:52 PST 2008
Author: lattner
Date: Tue Jan 22 13:34:51 2008
New Revision: 46256
URL: http://llvm.org/viewvc/llvm-project?rev=46256&view=rev
Log:
Fix PR1936, a crash on malformed #if. Thanks to Neil for
noticing this!
Modified:
cfe/trunk/Lex/Preprocessor.cpp
cfe/trunk/test/Preprocessor/ifdef-recover.c
Modified: cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Preprocessor.cpp?rev=46256&r1=46255&r2=46256&view=diff
==============================================================================
--- cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/Lex/Preprocessor.cpp Tue Jan 22 13:34:51 2008
@@ -939,9 +939,9 @@
// 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)) {
Modified: cfe/trunk/test/Preprocessor/ifdef-recover.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/ifdef-recover.c?rev=46256&r1=46255&r2=46256&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/ifdef-recover.c (original)
+++ cfe/trunk/test/Preprocessor/ifdef-recover.c Tue Jan 22 13:34:51 2008
@@ -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;
+
More information about the cfe-commits
mailing list