From ba3ca5271a01eae7cbd6a19ace004d75012c02a8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 6 Jan 2011 05:01:51 +0000 Subject: [PATCH] fix rdar://8823139, a crash on a comment in a preprocessed .s file that contains the ## operator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122946 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/PPDirectives.cpp | 6 ++++++ test/Preprocessor/assembler-with-cpp.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 5f4c321715..f422d254f0 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -654,6 +654,12 @@ TryAgain: // Return the # and the token after it. Toks[0] = SavedHash; Toks[1] = Result; + + // If the second token is a hashhash token, then we need to translate it to + // unknown so the token lexer doesn't try to perform token pasting. + if (Result.is(tok::hashhash)) + Toks[1].setKind(tok::unknown); + // Enter this token stream so that we re-lex the tokens. Make sure to // enable macro expansion, in case the token after the # is an identifier // that is expanded. diff --git a/test/Preprocessor/assembler-with-cpp.c b/test/Preprocessor/assembler-with-cpp.c index 0543077c01..a9c42940a3 100644 --- a/test/Preprocessor/assembler-with-cpp.c +++ b/test/Preprocessor/assembler-with-cpp.c @@ -72,3 +72,8 @@ 11: T11(b) // CHECK-Identifiers-True: 11: #0 + +// This should not crash +// rdar://8823139 +# ## +// CHECK-Identifiers-False: # ## -- 2.50.1