diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-06-13 19:02:56 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-06-13 19:02:56 +0000 |
commit | a60742a3d00ee31eca2eb41ef34abf3258dac937 (patch) | |
tree | c6f68d294c92416ea56544e4c5a7343abd1e57f9 /clang | |
parent | 429c134d5d447168c828be8510f94193162887d2 (diff) | |
download | bcm5719-llvm-a60742a3d00ee31eca2eb41ef34abf3258dac937.tar.gz bcm5719-llvm-a60742a3d00ee31eca2eb41ef34abf3258dac937.zip |
Fix issue where a token paste which forms a /* or // would discard the rest of
the input: token-pasting was producing a tok::eof.
Patch by Andy Gibbs!
llvm-svn: 158412
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Lex/TokenLexer.cpp | 4 | ||||
-rw-r--r-- | clang/test/Preprocessor/macro_paste_c_block_comment.c | 3 | ||||
-rw-r--r-- | clang/test/Preprocessor/macro_paste_identifier_error.c | 7 |
3 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index 696754c7416..81c9d0ab7ae 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/lib/Lex/TokenLexer.cpp @@ -568,8 +568,8 @@ bool TokenLexer::PasteTokens(Token &Tok) { << Buffer.str(); } - // Do not consume the RHS. - --CurToken; + // An error has occurred so exit loop. + break; } // Turn ## into 'unknown' to avoid # ## # from looking like a paste diff --git a/clang/test/Preprocessor/macro_paste_c_block_comment.c b/clang/test/Preprocessor/macro_paste_c_block_comment.c index c690a4c7c9f..92b2f601885 100644 --- a/clang/test/Preprocessor/macro_paste_c_block_comment.c +++ b/clang/test/Preprocessor/macro_paste_c_block_comment.c @@ -3,3 +3,6 @@ #define COMM / ## * COMM // expected-error {{pasting formed '/*', an invalid preprocessing token}} +// Demonstrate that an invalid preprocessing token +// doesn't swallow the rest of the file... +#error EOF // expected-error {{EOF}} diff --git a/clang/test/Preprocessor/macro_paste_identifier_error.c b/clang/test/Preprocessor/macro_paste_identifier_error.c new file mode 100644 index 00000000000..457e6f7fc1a --- /dev/null +++ b/clang/test/Preprocessor/macro_paste_identifier_error.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fms-extensions -Wno-invalid-token-paste %s -verify +// RUN: %clang_cc1 -E -fms-extensions -Wno-invalid-token-paste %s | FileCheck %s +// RUN: %clang_cc1 -E -fms-extensions -Wno-invalid-token-paste -x assembler-with-cpp %s | FileCheck %s + +#define foo a ## b ## = 0 +int foo; +// CHECK: int ab = 0; |