diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-06-15 19:48:50 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-06-15 19:48:50 +0000 |
commit | dd2ab963de3120382d3a4c4519ad3a2fc3b57924 (patch) | |
tree | 434a954048fda2600f25639a71dd5eb94ec0d9a5 | |
parent | e790614fa5e5bb54629ace77be453699c753a565 (diff) | |
download | bcm5719-llvm-dd2ab963de3120382d3a4c4519ad3a2fc3b57924.tar.gz bcm5719-llvm-dd2ab963de3120382d3a4c4519ad3a2fc3b57924.zip |
PR4395: Don't detect token concatenation in C mode for
C++-specific tokens.
llvm-svn: 73408
-rw-r--r-- | clang/lib/Lex/TokenConcatenation.cpp | 8 | ||||
-rw-r--r-- | clang/test/Lexer/token-concat-2.c | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Lex/TokenConcatenation.cpp b/clang/lib/Lex/TokenConcatenation.cpp index ab989cafc15..be13b274574 100644 --- a/clang/lib/Lex/TokenConcatenation.cpp +++ b/clang/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/clang/test/Lexer/token-concat-2.c b/clang/test/Lexer/token-concat-2.c new file mode 100644 index 00000000000..28916547d5b --- /dev/null +++ b/clang/test/Lexer/token-concat-2.c @@ -0,0 +1,4 @@ +// RUN: clang-cc -E -x c -o - %s | grep '[.][*]' +// PR4395 +#define X .* +X |