]> granicus.if.org Git - clang/commitdiff
Fix a crash on the testcase in PR9981 / rdar://9486765.
authorChris Lattner <sabre@nondot.org>
Tue, 14 Jun 2011 18:12:03 +0000 (18:12 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 14 Jun 2011 18:12:03 +0000 (18:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133003 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/TokenLexer.cpp
test/Preprocessor/macro_paste_bad.c

index 65aff0d1d037838af8fe6521385f2f1f01f1339d..751fd0133ea9bae17505e9266dce52c9b1a15929 100644 (file)
@@ -487,9 +487,10 @@ bool TokenLexer::PasteTokens(Token &Tok) {
           // 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.
index 2af0173040dc4da5fb7e487ae76753205e618549..1c0b74ba2982ad2660095b0249152df9baffd14c 100644 (file)
@@ -33,3 +33,9 @@ XX     // expected-error {{attempt to use a poisoned identifier}}
 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}}
+
+