[cfe-commits] r133003 - in /cfe/trunk: lib/Lex/TokenLexer.cpp test/Preprocessor/macro_paste_bad.c
Chris Lattner
sabre at nondot.org
Tue Jun 14 11:12:03 PDT 2011
Author: lattner
Date: Tue Jun 14 13:12:03 2011
New Revision: 133003
URL: http://llvm.org/viewvc/llvm-project?rev=133003&view=rev
Log:
Fix a crash on the testcase in PR9981 / rdar://9486765.
Modified:
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/test/Preprocessor/macro_paste_bad.c
Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=133003&r1=133002&r2=133003&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Tue Jun 14 13:12:03 2011
@@ -487,9 +487,10 @@
// Explicitly convert the token location to have proper instantiation
// information so that the user knows where it came from.
SourceManager &SM = PP.getSourceManager();
- SourceLocation Loc =
- SM.createInstantiationLoc(PasteOpLoc, InstantiateLocStart,
- InstantiateLocEnd, 2);
+ SourceLocation Loc = PasteOpLoc;
+ if (InstantiateLocStart.isValid())
+ Loc = SM.createInstantiationLoc(Loc, InstantiateLocStart,
+ InstantiateLocEnd, 2);
// If we're in microsoft extensions mode, downgrade this from a hard
// error to a warning that defaults to an error. This allows
// disabling it.
Modified: cfe/trunk/test/Preprocessor/macro_paste_bad.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_paste_bad.c?rev=133003&r1=133002&r2=133003&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/macro_paste_bad.c (original)
+++ cfe/trunk/test/Preprocessor/macro_paste_bad.c Tue Jun 14 13:12:03 2011
@@ -33,3 +33,9 @@
int VA; // expected-warning {{__VA_ARGS__ can only appear in the expansion of a C99 variadic macro}}
+// PR9981
+#define M1(A) A
+#define M2(X)
+M1(M2(##)) // expected-error {{pasting formed '()', an invalid preprocessing token}}
+
+
More information about the cfe-commits
mailing list