[cfe-commits] r158412 - in /cfe/trunk: lib/Lex/TokenLexer.cpp test/Preprocessor/macro_paste_c_block_comment.c test/Preprocessor/macro_paste_identifier_error.c

Richard Smith richard-llvm at metafoo.co.uk
Wed Jun 13 12:02:56 PDT 2012


Author: rsmith
Date: Wed Jun 13 14:02:56 2012
New Revision: 158412

URL: http://llvm.org/viewvc/llvm-project?rev=158412&view=rev
Log:
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!

Added:
    cfe/trunk/test/Preprocessor/macro_paste_identifier_error.c
Modified:
    cfe/trunk/lib/Lex/TokenLexer.cpp
    cfe/trunk/test/Preprocessor/macro_paste_c_block_comment.c

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=158412&r1=158411&r2=158412&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Wed Jun 13 14:02:56 2012
@@ -568,8 +568,8 @@
             << 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

Modified: cfe/trunk/test/Preprocessor/macro_paste_c_block_comment.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_paste_c_block_comment.c?rev=158412&r1=158411&r2=158412&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/macro_paste_c_block_comment.c (original)
+++ cfe/trunk/test/Preprocessor/macro_paste_c_block_comment.c Wed Jun 13 14:02:56 2012
@@ -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}}

Added: cfe/trunk/test/Preprocessor/macro_paste_identifier_error.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_paste_identifier_error.c?rev=158412&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/macro_paste_identifier_error.c (added)
+++ cfe/trunk/test/Preprocessor/macro_paste_identifier_error.c Wed Jun 13 14:02:56 2012
@@ -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;





More information about the cfe-commits mailing list