Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79684 - in trunk: boost/wave/util libs/wave libs/wave/test/testwave/testfiles
From: hartmut.kaiser_at_[hidden]
Date: 2012-07-22 19:08:33


Author: hkaiser
Date: 2012-07-22 19:08:25 EDT (Sun, 22 Jul 2012)
New Revision: 79684
URL: http://svn.boost.org/trac/boost/changeset/79684

Log:
Fixed #7159: Text-lines are processed as if they were preprocessing directives
Added:
   trunk/libs/wave/test/testwave/testfiles/t_9_021.cpp (contents, props changed)
   trunk/libs/wave/test/testwave/testfiles/t_9_022.cpp (contents, props changed)
Text files modified:
   trunk/boost/wave/util/cpp_iterator.hpp | 17 +++++++++++++----
   trunk/libs/wave/ChangeLog | 1 +
   trunk/libs/wave/test/testwave/testfiles/test.cfg | 2 ++
   3 files changed, 16 insertions(+), 4 deletions(-)

Modified: trunk/boost/wave/util/cpp_iterator.hpp
==============================================================================
--- trunk/boost/wave/util/cpp_iterator.hpp (original)
+++ trunk/boost/wave/util/cpp_iterator.hpp 2012-07-22 19:08:25 EDT (Sun, 22 Jul 2012)
@@ -466,7 +466,8 @@
     template <typename ContextT>
     bool consider_emitting_line_directive(ContextT const& ctx, token_id id)
     {
- if (need_preserve_comments(ctx.get_language())) {
+ if (need_preserve_comments(ctx.get_language()))
+ {
             if (!IS_CATEGORY(id, EOLTokenType) && !IS_CATEGORY(id, EOFTokenType))
             {
                 return true;
@@ -475,7 +476,7 @@
         if (!IS_CATEGORY(id, WhiteSpaceTokenType) &&
             !IS_CATEGORY(id, EOLTokenType) && !IS_CATEGORY(id, EOFTokenType))
         {
- return true;
+ return true;
         }
         return false;
     }
@@ -492,13 +493,17 @@
 
     // loop over skip able whitespace until something significant is found
     bool was_seen_newline = seen_newline;
+ bool was_skipped_newline = false;
     token_id id = T_UNKNOWN;
 
     try { // catch lexer exceptions
         do {
+ if (skipped_newline) {
+ was_skipped_newline = true;
+ skipped_newline = false;
+ }
+
         // get_next_token assigns result to act_token member
- if (skipped_newline)
- seen_newline = true;
             get_next_token();
 
         // if comments shouldn't be preserved replace them with newlines
@@ -518,6 +523,10 @@
         return act_token;
     }
 
+// restore the accumulated skipped_newline state for next invocation
+ if (was_skipped_newline)
+ skipped_newline = true;
+
 // if there were skipped any newlines, we must emit a #line directive
     if ((must_emit_line_directive || (was_seen_newline && skipped_newline)) &&
         impl::consider_emitting_line_directive(ctx, id))

Modified: trunk/libs/wave/ChangeLog
==============================================================================
--- trunk/libs/wave/ChangeLog (original)
+++ trunk/libs/wave/ChangeLog 2012-07-22 19:08:25 EDT (Sun, 22 Jul 2012)
@@ -22,6 +22,7 @@
 
 Boost V1.51.0
  - Fixed #7050: Invalid memory write bug in lexing_exception
+ - Fixed #7159: Text-lines are processed as if they were preprocessing directives
 
 Boost V1.50.0
  - V2.3.2

Added: trunk/libs/wave/test/testwave/testfiles/t_9_021.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/wave/test/testwave/testfiles/t_9_021.cpp 2012-07-22 19:08:25 EDT (Sun, 22 Jul 2012)
@@ -0,0 +1,24 @@
+/*=============================================================================
+ Boost.Wave: A Standard compliant C++ preprocessor library
+ http://www.boost.org/
+
+ Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
+ Software License, Version 1.0. (See accompanying file
+ LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+// Verifies that preprocessing directives are properly recognized only if
+// the '#' is really the first character on a line before macro expansion.
+// See http://www.open-std.org/jtc1/sc22/wg14/docs/rr/dr_144.html.
+
+#define EMPTY
+EMPTY # define M 1
+
+//R #line 15 "t_9_021.cpp"
+//R #define M 1
+
+//H 10: t_9_021.cpp(14): #define
+//H 08: t_9_021.cpp(14): EMPTY=
+//H 01: t_9_021.cpp(14): EMPTY
+//H 02:
+//H 03: _

Added: trunk/libs/wave/test/testwave/testfiles/t_9_022.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/wave/test/testwave/testfiles/t_9_022.cpp 2012-07-22 19:08:25 EDT (Sun, 22 Jul 2012)
@@ -0,0 +1,18 @@
+/*=============================================================================
+ Boost.Wave: A Standard compliant C++ preprocessor library
+ http://www.boost.org/
+
+ Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
+ Software License, Version 1.0. (See accompanying file
+ LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+// Verifies that preprocessing directives are properly recognized only if
+// the '#' is really the first character on a line before macro expansion.
+// See http://www.open-std.org/jtc1/sc22/wg14/docs/rr/dr_144.html.
+
+#define EMPTY
+# EMPTY define M 1
+
+//E t_9_022.cpp(15): error: ill formed preprocessor directive: # EMPTY define M 1
+

Modified: trunk/libs/wave/test/testwave/testfiles/test.cfg
==============================================================================
--- trunk/libs/wave/test/testwave/testfiles/test.cfg (original)
+++ trunk/libs/wave/test/testwave/testfiles/test.cfg 2012-07-22 19:08:25 EDT (Sun, 22 Jul 2012)
@@ -236,3 +236,5 @@
 t_9_018.cpp
 t_9_019.cpp
 t_9_020.cpp
+t_9_021.cpp
+t_9_022.cpp


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk