From: Eli Friedman Date: Mon, 15 Jun 2009 19:48:50 +0000 (+0000) Subject: PR4395: Don't detect token concatenation in C mode for X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8849f1190330c493a89b0088557d1a2333465847;p=clang PR4395: Don't detect token concatenation in C mode for C++-specific tokens. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73408 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/TokenConcatenation.cpp b/lib/Lex/TokenConcatenation.cpp index ab989cafc1..be13b27457 100644 --- a/lib/Lex/TokenConcatenation.cpp +++ b/lib/Lex/TokenConcatenation.cpp @@ -192,7 +192,8 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevTok, return isalnum(FirstChar) || Tok.is(tok::numeric_constant) || FirstChar == '+' || FirstChar == '-' || FirstChar == '.'; case tok::period: // ..., .*, .1234 - return FirstChar == '.' || isdigit(FirstChar) || FirstChar == '*'; + return FirstChar == '.' || isdigit(FirstChar) || + (PP.getLangOptions().CPlusPlus && FirstChar == '*'); case tok::amp: // && return FirstChar == '&'; case tok::plus: // ++ @@ -210,10 +211,11 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevTok, case tok::percent: // %>, %: return FirstChar == '>' || FirstChar == ':'; case tok::colon: // ::, :> - return FirstChar == ':' ||FirstChar == '>'; + return FirstChar == '>' || + (PP.getLangOptions().CPlusPlus && FirstChar == ':'); case tok::hash: // ##, #@, %:%: return FirstChar == '#' || FirstChar == '@' || FirstChar == '%'; case tok::arrow: // ->* - return FirstChar == '*'; + return PP.getLangOptions().CPlusPlus && FirstChar == '*'; } } diff --git a/test/Lexer/token-concat-2.c b/test/Lexer/token-concat-2.c new file mode 100644 index 0000000000..28916547d5 --- /dev/null +++ b/test/Lexer/token-concat-2.c @@ -0,0 +1,4 @@ +// RUN: clang-cc -E -x c -o - %s | grep '[.][*]' +// PR4395 +#define X .* +X