Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,15 @@ lexer<IteratorT, PositionT, TokenT>::lexer(IteratorT const &first,
scanner.act_in_cpp0x_mode = false;
#endif

#if BOOST_WAVE_SUPPORT_CPP1Z != 0
scanner.act_in_cpp0x_mode = boost::wave::need_cpp1z(language_)
|| boost::wave::need_cpp0x(language_);
#endif

#if BOOST_WAVE_SUPPORT_CPP2A != 0
scanner.act_in_cpp2a_mode = boost::wave::need_cpp2a(language_);
scanner.act_in_cpp0x_mode = boost::wave::need_cpp2a(language_)
|| boost::wave::need_cpp1z(language_)
|| boost::wave::need_cpp0x(language_);
#else
scanner.act_in_cpp2a_mode = false;
Expand All @@ -167,6 +173,7 @@ lexer<IteratorT, PositionT, TokenT>::lexer(IteratorT const &first,
|| boost::wave::need_cpp2a(language_);
scanner.act_in_cpp0x_mode = boost::wave::need_cpp2b(language_)
|| boost::wave::need_cpp2a(language_)
|| boost::wave::need_cpp1z(language_)
|| boost::wave::need_cpp0x(language_);
#else
scanner.act_in_cpp2b_mode = false;
Expand Down
25 changes: 25 additions & 0 deletions include/boost/wave/language_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,31 @@ need_cpp0x(language_support language)

#endif

///////////////////////////////////////////////////////////////////////////////
//
// need_cpp1z
//
// Extract if the language to support is C++17
//
///////////////////////////////////////////////////////////////////////////////
#if BOOST_WAVE_SUPPORT_CPP1Z != 0

inline bool
need_cpp1z(language_support language)
{
return (language & ~support_option_mask) == support_cpp1z;
}

#else

inline bool
need_cpp1z(language_support language)
{
return false;
}

#endif

///////////////////////////////////////////////////////////////////////////////
//
// need_cpp2a
Expand Down
22 changes: 22 additions & 0 deletions include/boost/wave/util/cpp_macromap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,17 @@ macromap<ContextT>::init_predefined_macros(char const *fname,
}
else
#endif
#if BOOST_WAVE_SUPPORT_CPP1Z != 0
if (boost::wave::need_cpp1z(ctx.get_language())) {
// define C++17 specifics
for (int i = 0; 0 != predef.static_data_cpp1z(i).name; ++i) {
predefined_macros::static_macros const& m = predef.static_data_cpp1z(i);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really formatted like this or is this some kind of artifact...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. The #if and #endif were indented instead of being at the beginning of the lines. Now the code is formatted exactly like the code around it.

predefine_macro(current_scope, m.name,
token_type(m.token_id, m.value, pos));
}
}
else
#endif
#if BOOST_WAVE_SUPPORT_CPP2A != 0
if (boost::wave::need_cpp2a(ctx.get_language())) {
// define C++20 specifics
Expand All @@ -2233,6 +2244,17 @@ macromap<ContextT>::init_predefined_macros(char const *fname,
}
}
else
#endif
#if BOOST_WAVE_SUPPORT_CPP2B != 0
if (boost::wave::need_cpp2b(ctx.get_language())) {
// define C++23 specifics
for (int i = 0; 0 != predef.static_data_cpp2b(i).name; ++i) {
predefined_macros::static_macros const& m = predef.static_data_cpp2b(i);
predefine_macro(current_scope, m.name,
token_type(m.token_id, m.value, pos));
}
}
else
#endif
{
// define C++ specifics
Expand Down
34 changes: 34 additions & 0 deletions include/boost/wave/util/cpp_macromap_predef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,23 @@ namespace util {
}
#endif

#if BOOST_WAVE_SUPPORT_CPP1Z != 0
// C++17 mode
static_macros const& static_data_cpp1z(std::size_t i) const
{
static static_macros data[] = {
{ "__STDC__", T_INTLIT, "1" },
{ "__cplusplus", T_INTLIT, "201703L" },
{ "__STDC_VERSION__", T_INTLIT, "199901L" },
{ "__STDC_HOSTED__", T_INTLIT, "0" },
{ "__WAVE_HAS_VARIADICS__", T_INTLIT, "1" },
{ 0, T_EOF, 0 }
};
BOOST_ASSERT(i < sizeof(data)/sizeof(data[0]));
return data[i];
}
#endif

#if BOOST_WAVE_SUPPORT_CPP2A != 0
// C++20 mode
static_macros const& static_data_cpp2a(std::size_t i) const
Expand All @@ -255,6 +272,23 @@ namespace util {
}
#endif

#if BOOST_WAVE_SUPPORT_CPP2B != 0
// C++23 mode
static_macros const& static_data_cpp2b(std::size_t i) const
{
static static_macros data[] = {
{ "__STDC__", T_INTLIT, "1" },
{ "__cplusplus", T_INTLIT, "202302L" },
Comment thread
jefftrull marked this conversation as resolved.
{ "__STDC_VERSION__", T_INTLIT, "199901L" },
{ "__STDC_HOSTED__", T_INTLIT, "0" },
{ "__WAVE_HAS_VARIADICS__", T_INTLIT, "1" },
{ 0, T_EOF, 0 }
};
BOOST_ASSERT(i < sizeof(data)/sizeof(data[0]));
return data[i];
}
#endif

#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
// C99 mode
static_macros const& static_data_c99(std::size_t i) const
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp_tokens/slex/cpp_slex_lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ lexer<IteratorT, PositionT>::init_dfa(boost::wave::language_support lang)

// if in C++0x mode, add appropriate keywords
#if BOOST_WAVE_SUPPORT_CPP0X != 0
if (boost::wave::need_cpp0x(lang) || boost::wave::need_cpp2a(lang) || boost::wave::need_cpp2b(lang)) {
if (boost::wave::need_cpp0x(lang) || boost::wave::need_cpp1z(lang) || boost::wave::need_cpp2a(lang) || boost::wave::need_cpp2b(lang)) {
for (int j = 0; 0 != init_data_cpp0x[j].tokenid; ++j) {
this->register_regex(init_data_cpp0x[j].tokenregex,
init_data_cpp0x[j].tokenid, init_data_cpp0x[j].tokencb,
Expand Down
2 changes: 1 addition & 1 deletion samples/list_includes/lexertl/lexertl_lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ std::ifstream dfa_in("wave_lexertl_lexer.dfa", std::ios::in|std::ios::binary);

// if in C++0x mode, add appropriate keywords
#if BOOST_WAVE_SUPPORT_CPP0X != 0
if (wave::need_cpp0x(lang) || wave::need_cpp2a(lang) || wave::need_cpp2b(lang)) {
if (wave::need_cpp0x(lang) || wave::need_cpp1z(lang) || wave::need_cpp2a(lang) || wave::need_cpp2b(lang)) {
for (int j = 0; 0 != init_data_cpp0x[j].tokenid; ++j) {
rules.add(init_data_cpp0x[j].tokenregex,
init_data_cpp0x[j].tokenid);
Expand Down
2 changes: 1 addition & 1 deletion samples/token_statistics/xlex/xlex_lexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ lexer<Iterator, Position>::lexer(Iterator const &first,
}

#if BOOST_WAVE_SUPPORT_CPP0X != 0
if (boost::wave::need_cpp0x(language) || boost::wave::need_cpp2a(language) || boost::wave::need_cpp2b(language)) {
if (boost::wave::need_cpp0x(language) || boost::wave::need_cpp1z(language) || boost::wave::need_cpp2a(language) || boost::wave::need_cpp2b(language)) {
for (int j = 0; 0 != init_data_cpp0x[j].tokenid; ++j) {
xlexer.register_regex(init_data_cpp0x[j].tokenregex,
init_data_cpp0x[j].tokenid, init_data_cpp[j].tokencb);
Expand Down
18 changes: 18 additions & 0 deletions test/testwave/testfiles/t_3_006.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library

Copyright (c) 2026 Martin Medler. 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)
=============================================================================*/

// Verify the C++98 values of of the predefined macros

// C++98 is the default and can't be set explicitly via '--c++XX' in this test framework

//R #line 14 "t_3_006.cpp"
__cplusplus //R 199711L

//H 01: <built-in>(1): __cplusplus
//H 02: 199711L
//H 03: 199711L
18 changes: 18 additions & 0 deletions test/testwave/testfiles/t_3_007.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library

Copyright (c) 2026 Martin Medler. 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)
=============================================================================*/

// Verify the C++11 values of of the predefined macros

//O --c++11

//R #line 14 "t_3_007.cpp"
__cplusplus //R 201103L

//H 01: <built-in>(1): __cplusplus
//H 02: 201103L
//H 03: 201103L
18 changes: 18 additions & 0 deletions test/testwave/testfiles/t_3_009.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library

Copyright (c) 2026 Martin Medler. 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)
=============================================================================*/

// Verify the C++17 values of of the predefined macros

//O --c++17

//R #line 14 "t_3_009.cpp"
__cplusplus //R 201703L

//H 01: <built-in>(1): __cplusplus
//H 02: 201703L
//H 03: 201703L
18 changes: 18 additions & 0 deletions test/testwave/testfiles/t_3_010.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library

Copyright (c) 2026 Martin Medler. 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)
=============================================================================*/

// Verify the C++20 values of of the predefined macros

//O --c++20

//R #line 14 "t_3_010.cpp"
__cplusplus //R 202002L

//H 01: <built-in>(1): __cplusplus
//H 02: 202002L
//H 03: 202002L
18 changes: 18 additions & 0 deletions test/testwave/testfiles/t_3_011.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library

Copyright (c) 2026 Martin Medler. 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)
=============================================================================*/

// Verify the C++23 values of of the predefined macros

//O --c++23

//R #line 14 "t_3_011.cpp"
__cplusplus //R 202302L

//H 01: <built-in>(1): __cplusplus
//H 02: 202302L
//H 03: 202302L
5 changes: 5 additions & 0 deletions test/testwave/testfiles/test.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ t_3_002.cpp
t_3_003.cpp
t_3_004.cpp
t_3_005.cpp
t_3_006.cpp
t_3_007.cpp
t_3_009.cpp
t_3_010.cpp
t_3_011.cpp

#
# Preprocessing expressions
Expand Down
Loading