From 76dbbf96b37a44ad21fa0ba56558e578522aa8eb Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Mon, 23 Jul 2012 00:21:37 +0000 Subject: [PATCH] Wave: merging from trunk [SVN r79689] --- ChangeLog | 5 +++ include/boost/wave/cpp_exceptions.hpp | 2 +- .../boost/wave/cpplexer/cpp_lex_iterator.hpp | 2 +- .../wave/cpplexer/re2clex/cpp_re2c_lexer.hpp | 2 +- .../boost/wave/cpplexer/re2clex/scanner.hpp | 2 +- include/boost/wave/language_support.hpp | 37 ++++++++++--------- include/boost/wave/token_ids.hpp | 2 +- include/boost/wave/util/cpp_iterator.hpp | 17 +++++++-- include/boost/wave/util/cpp_macromap.hpp | 4 +- .../boost/wave/util/cpp_macromap_predef.hpp | 2 +- include/boost/wave/wave_config.hpp | 4 +- include/boost/wave/whitespace_handling.hpp | 2 +- test/testwave/testfiles/t_7_001.cpp | 2 +- test/testwave/testfiles/t_9_021.cpp | 24 ++++++++++++ test/testwave/testfiles/t_9_022.cpp | 18 +++++++++ test/testwave/testfiles/test.cfg | 2 + test/testwave/testwave_app.cpp | 6 +-- tool/cpp.cpp | 10 ++--- 18 files changed, 101 insertions(+), 42 deletions(-) create mode 100644 test/testwave/testfiles/t_9_021.cpp create mode 100644 test/testwave/testfiles/t_9_022.cpp diff --git a/ChangeLog b/ChangeLog index b895a21..082523b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,11 @@ TODO (known issues): CHANGELOG +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 + - Changed --c++0x command line option to --c++11. + Boost V1.50.0 - V2.3.2 - Fixed #6758: not all members are initialized by base_iteration_context diff --git a/include/boost/wave/cpp_exceptions.hpp b/include/boost/wave/cpp_exceptions.hpp index 584c04d..3af69ea 100644 --- a/include/boost/wave/cpp_exceptions.hpp +++ b/include/boost/wave/cpp_exceptions.hpp @@ -283,7 +283,7 @@ public: "a macro or scope name", // alreadydefined_name "undefined macro or scope name may not be imported", // undefined_macroname "ill formed macro name", // invalid_macroname - "qualified names are supported in C++0x mode only", // unexpected_qualified_name + "qualified names are supported in C++11 mode only", // unexpected_qualified_name "division by zero in preprocessor expression", // division_by_zero "integer overflow in preprocessor expression", // integer_overflow "this cannot be used as a macro name as it is " diff --git a/include/boost/wave/cpplexer/cpp_lex_iterator.hpp b/include/boost/wave/cpplexer/cpp_lex_iterator.hpp index 10b032a..580873c 100644 --- a/include/boost/wave/cpplexer/cpp_lex_iterator.hpp +++ b/include/boost/wave/cpplexer/cpp_lex_iterator.hpp @@ -133,7 +133,7 @@ typename lex_iterator_functor_shim::result_type const // a third parameter containing the name of the parsed input file // and a 4th parameter of the type boost::wave::language_support // which specifies, which language subset should be supported (C++, -// C99, C++0x etc.). +// C99, C++11 etc.). // /////////////////////////////////////////////////////////////////////////////// diff --git a/include/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp b/include/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp index fa4b202..d22a015 100644 --- a/include/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp +++ b/include/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp @@ -219,7 +219,7 @@ lexer::get(TokenT& result) } #endif - case T_LONGINTLIT: // supported in C++0x, C99 and long_long mode + case T_LONGINTLIT: // supported in C++11, C99 and long_long mode value = string_type((char const *)scanner.tok, scanner.cur-scanner.tok); if (!boost::wave::need_long_long(language)) { diff --git a/include/boost/wave/cpplexer/re2clex/scanner.hpp b/include/boost/wave/cpplexer/re2clex/scanner.hpp index 11c5acd..1c696cf 100644 --- a/include/boost/wave/cpplexer/re2clex/scanner.hpp +++ b/include/boost/wave/cpplexer/re2clex/scanner.hpp @@ -57,7 +57,7 @@ typedef struct Scanner { bool detect_pp_numbers; /* lexer should prefer to detect pp-numbers */ bool enable_import_keyword; /* recognize import as a keyword */ bool single_line_only; /* don't report missing eol's in C++ comments */ - bool act_in_cpp0x_mode; /* lexer works in C++0x mode */ + bool act_in_cpp0x_mode; /* lexer works in C++11 mode */ } Scanner; /////////////////////////////////////////////////////////////////////////////// diff --git a/include/boost/wave/language_support.hpp b/include/boost/wave/language_support.hpp index 1711c19..df8839c 100644 --- a/include/boost/wave/language_support.hpp +++ b/include/boost/wave/language_support.hpp @@ -1,7 +1,7 @@ /*============================================================================= Boost.Wave: A Standard compliant C++ preprocessor library Definition of the various language support constants - + http://www.boost.org/ Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost @@ -33,9 +33,10 @@ enum language_support { // support flags for C99 support_option_variadics = 0x04, support_c99 = support_option_variadics | support_option_long_long | 0x08, -#endif +#endif #if BOOST_WAVE_SUPPORT_CPP0X != 0 support_cpp0x = support_option_variadics | support_option_long_long | 0x10, + support_cpp11 = support_cpp0x, #endif support_option_mask = 0xFFB0, @@ -52,29 +53,29 @@ enum language_support { }; /////////////////////////////////////////////////////////////////////////////// -// +// // need_cpp // // Extract, if the language to support is C++98 // /////////////////////////////////////////////////////////////////////////////// inline bool -need_cpp(language_support language) +need_cpp(language_support language) { return (language & ~support_option_mask) == support_cpp; } /////////////////////////////////////////////////////////////////////////////// -// +// // need_cpp0x // -// Extract, if the language to support is C++0x +// Extract, if the language to support is C++11 // /////////////////////////////////////////////////////////////////////////////// #if BOOST_WAVE_SUPPORT_CPP0X != 0 inline bool -need_cpp0x(language_support language) +need_cpp0x(language_support language) { return (language & ~support_option_mask) == support_cpp0x; } @@ -82,7 +83,7 @@ need_cpp0x(language_support language) #else inline bool -need_cpp0x(language_support language) +need_cpp0x(language_support language) { return false; } @@ -91,14 +92,14 @@ need_cpp0x(language_support language) #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 /////////////////////////////////////////////////////////////////////////////// -// +// // need_c99 // // Extract, if the language to support is C99 // /////////////////////////////////////////////////////////////////////////////// inline bool -need_c99(language_support language) +need_c99(language_support language) { return (language & ~support_option_mask) == support_c99; } @@ -106,8 +107,8 @@ need_c99(language_support language) #else // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 /////////////////////////////////////////////////////////////////////////////// -inline bool -need_variadics(language_support language) +inline bool +need_variadics(language_support language) { return false; } @@ -121,7 +122,7 @@ enable_variadics(language_support language, bool enable = true) ////////////////////////////////////////////////////////////////////////////// inline bool -need_c99(language_support language) +need_c99(language_support language) { return false; } @@ -129,7 +130,7 @@ need_c99(language_support language) #endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 /////////////////////////////////////////////////////////////////////////////// -// +// // get_support_options // // Set preserve comments support in the language to support @@ -142,7 +143,7 @@ get_support_options(language_support language) } /////////////////////////////////////////////////////////////////////////////// -// +// // set_support_options // // Set language option (for fine tuning of lexer behavior) @@ -178,7 +179,7 @@ set_support_options(language_support language, language_support option) BOOST_WAVE_NEED_OPTION(option) \ BOOST_WAVE_ENABLE_OPTION(option) \ /**/ - + /////////////////////////////////////////////////////////////////////////////// BOOST_WAVE_OPTION(long_long) // support_option_long_long BOOST_WAVE_OPTION(no_character_validation) // support_option_no_character_validation @@ -192,7 +193,7 @@ BOOST_WAVE_OPTION(include_guard_detection) // support_option_include_guard_dete #endif #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 BOOST_WAVE_OPTION(variadics) // support_option_variadics -#endif +#endif #if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0 BOOST_WAVE_OPTION(emit_pragma_directives) // support_option_emit_pragma_directives #endif @@ -205,7 +206,7 @@ BOOST_WAVE_OPTION(emit_contnewlines) // support_option_emit_contnewlines /////////////////////////////////////////////////////////////////////////////// } // namespace wave -} // namespace boost +} // namespace boost // the suffix header occurs after all of the code #ifdef BOOST_HAS_ABI_HEADERS diff --git a/include/boost/wave/token_ids.hpp b/include/boost/wave/token_ids.hpp index e75743c..eb4368c 100644 --- a/include/boost/wave/token_ids.hpp +++ b/include/boost/wave/token_ids.hpp @@ -287,7 +287,7 @@ enum token_id { // import is needed to be a keyword for the C++ module Standards proposal T_IMPORT = TOKEN_FROM_ID(421, KeywordTokenType), -// C++0x keywords +// C++11 keywords T_ALIGNAS = TOKEN_FROM_ID(422, KeywordTokenType), T_ALIGNOF = TOKEN_FROM_ID(423, KeywordTokenType), T_CHAR16_T = TOKEN_FROM_ID(424, KeywordTokenType), diff --git a/include/boost/wave/util/cpp_iterator.hpp b/include/boost/wave/util/cpp_iterator.hpp index 5b6bcc3..e6271ac 100644 --- a/include/boost/wave/util/cpp_iterator.hpp +++ b/include/boost/wave/util/cpp_iterator.hpp @@ -466,7 +466,8 @@ namespace impl { template 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 @@ namespace impl { if (!IS_CATEGORY(id, WhiteSpaceTokenType) && !IS_CATEGORY(id, EOLTokenType) && !IS_CATEGORY(id, EOFTokenType)) { - return true; + return true; } return false; } @@ -492,13 +493,17 @@ pp_iterator_functor::operator()() // loop over skip able whitespace until something significant is found bool was_seen_newline = seen_newline; + bool was_skipped_newline = skipped_newline; 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 @@ pp_iterator_functor::operator()() 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)) diff --git a/include/boost/wave/util/cpp_macromap.hpp b/include/boost/wave/util/cpp_macromap.hpp index 928bf58..182567e 100644 --- a/include/boost/wave/util/cpp_macromap.hpp +++ b/include/boost/wave/util/cpp_macromap.hpp @@ -1641,7 +1641,7 @@ macromap::is_valid_concat(string_type new_value, for (/**/; it != end && T_EOF != token_id(*it); ++it) { // as of Wave V2.0.7 pasting of tokens is valid only if the resulting - // tokens are pp_tokens (as mandated by C++0x) + // tokens are pp_tokens (as mandated by C++11) if (!is_pp_token(*it)) return false; rescanned.push_back(*it); @@ -1847,7 +1847,7 @@ position_type pos(""); { #if BOOST_WAVE_SUPPORT_CPP0X != 0 if (boost::wave::need_cpp0x(ctx.get_language())) { - // define C++0x specifics + // define C++11 specifics for (int i = 0; 0 != predef.static_data_cpp0x(i).name; ++i) { predefined_macros::static_macros const& m = predef.static_data_cpp0x(i); predefine_macro(current_scope, m.name, diff --git a/include/boost/wave/util/cpp_macromap_predef.hpp b/include/boost/wave/util/cpp_macromap_predef.hpp index fd6b85a..74ba2ad 100644 --- a/include/boost/wave/util/cpp_macromap_predef.hpp +++ b/include/boost/wave/util/cpp_macromap_predef.hpp @@ -224,7 +224,7 @@ namespace util { } #if BOOST_WAVE_SUPPORT_CPP0X != 0 - // C++0x mode + // C++11 mode static_macros const& static_data_cpp0x(std::size_t i) const { static static_macros data[] = { diff --git a/include/boost/wave/wave_config.hpp b/include/boost/wave/wave_config.hpp index 1c841a7..ec712ef 100644 --- a/include/boost/wave/wave_config.hpp +++ b/include/boost/wave/wave_config.hpp @@ -83,9 +83,9 @@ #endif /////////////////////////////////////////////////////////////////////////////// -// Decide, whether to support C++0x +// Decide, whether to support C++11 // -// To implement C++0x keywords and preprocessor semantics define the following +// To implement C++11 keywords and preprocessor semantics define the following // to something not equal to zero. // #if !defined(BOOST_WAVE_SUPPORT_CPP0X) diff --git a/include/boost/wave/whitespace_handling.hpp b/include/boost/wave/whitespace_handling.hpp index 6fd1dfd..c81a67c 100644 --- a/include/boost/wave/whitespace_handling.hpp +++ b/include/boost/wave/whitespace_handling.hpp @@ -67,7 +67,7 @@ namespace util { #if BOOST_WAVE_SUPPORT_CPP0X != 0 /////////////////////////////////////////////////////////////////////////// - // This function returns the number of newlines in the given C++0x style + // This function returns the number of newlines in the given C++11 style // raw string template int rawstring_count_newlines(TokenT const& token) diff --git a/test/testwave/testfiles/t_7_001.cpp b/test/testwave/testfiles/t_7_001.cpp index 5ac230b..7c35779 100644 --- a/test/testwave/testfiles/t_7_001.cpp +++ b/test/testwave/testfiles/t_7_001.cpp @@ -7,7 +7,7 @@ LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ -//O --c++0x +//O --c++11 //R #line 16 "t_7_001.cpp" //R R"de diff --git a/test/testwave/testfiles/t_9_021.cpp b/test/testwave/testfiles/t_9_021.cpp new file mode 100644 index 0000000..84b0e33 --- /dev/null +++ b/test/testwave/testfiles/t_9_021.cpp @@ -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: _ diff --git a/test/testwave/testfiles/t_9_022.cpp b/test/testwave/testfiles/t_9_022.cpp new file mode 100644 index 0000000..119018e --- /dev/null +++ b/test/testwave/testfiles/t_9_022.cpp @@ -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 + diff --git a/test/testwave/testfiles/test.cfg b/test/testwave/testfiles/test.cfg index 65debd7..77129fb 100644 --- a/test/testwave/testfiles/test.cfg +++ b/test/testwave/testfiles/test.cfg @@ -236,3 +236,5 @@ t_9_017.cpp t_9_018.cpp t_9_019.cpp t_9_020.cpp +t_9_021.cpp +t_9_022.cpp diff --git a/test/testwave/testwave_app.cpp b/test/testwave/testwave_app.cpp index d2f9c1a..a6cb0e6 100644 --- a/test/testwave/testwave_app.cpp +++ b/test/testwave/testwave_app.cpp @@ -371,7 +371,7 @@ testwave_app::testwave_app(po::variables_map const& vm) #endif ("skipped_token_hooks", "record skipped_token hook calls") #if BOOST_WAVE_SUPPORT_CPP0X != 0 - ("c++0x", "enable C99 mode (implies --variadics and --long_long)") + ("c++11", "enable C++11 mode (implies --variadics and --long_long)") #endif ; } @@ -914,9 +914,9 @@ testwave_app::initialise_options(Context& ctx, po::variables_map const& vm, #endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 #if BOOST_WAVE_SUPPORT_CPP0X - if (vm.count("c++0x")) { + if (vm.count("c++11")) { if (9 == debuglevel) { - std::cerr << "initialise_options: option: c++0x" << std::endl; + std::cerr << "initialise_options: option: c++11" << std::endl; } ctx.set_language( boost::wave::language_support( diff --git a/tool/cpp.cpp b/tool/cpp.cpp index 6a1d010..023d8fd 100644 --- a/tool/cpp.cpp +++ b/tool/cpp.cpp @@ -808,9 +808,9 @@ int error_count = 0; // enable C99 mode, if appropriate (implies variadics) if (vm.count("c99")) { #if BOOST_WAVE_SUPPORT_CPP0X != 0 - if (vm.count("c++0x")) { + if (vm.count("c++11")) { cerr << "wave: multiple language options specified: --c99 " - "and --c++0x" << endl; + "and --c++11" << endl; return -1; } #endif @@ -834,10 +834,10 @@ int error_count = 0; } #endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0 #if BOOST_WAVE_SUPPORT_CPP0X != 0 - if (vm.count("c++0x")) { + if (vm.count("c++11")) { if (vm.count("c99")) { cerr << "wave: multiple language options specified: --c99 " - "and --c++0x" << endl; + "and --c++11" << endl; return -1; } ctx.set_language( @@ -1271,7 +1271,7 @@ main (int argc, char *argv[]) ("c99", "enable C99 mode (implies --variadics)") #endif #if BOOST_WAVE_SUPPORT_CPP0X != 0 - ("c++0x", "enable C++0x mode (implies --variadics and --long_long)") + ("c++11", "enable C++11 mode (implies --variadics and --long_long)") #endif ("listincludes,l", po::value(), "list names of included files to a file [arg] or to stdout [-]")