2
0
mirror of https://github.com/boostorg/wave.git synced 2026-01-20 05:02:45 +00:00

98 Commits

Author SHA1 Message Date
Jeff Trull
ac31d13c6a Implement support for digit separators in preprocessor expressions
Integers with digit separators are already recognized as literal
tokens. This commit adds proper interpretation of them as integers for
use in expressions e.g. with #if
2025-11-16 17:23:04 -08:00
njnobles
ffdc3419a3 Emit line directives for includes with directive on first line (#223)
* Emit line directives for includes with directive on first line
* Add nested include tests

Thanks to Nick Nobles for this bug report and fix
2024-10-03 12:49:37 -07:00
jwnhy
ef14767aec Fix empty stringify under C++20 (#221)
* fix segment fault of empty stringify under C++20
* Add tests for optional comma in variadic macro call

---------

Co-authored-by: Jeff Trull <edaskel@att.net>
2024-09-15 14:42:33 +10:00
Jeff Trull
df2125a1bd Repair Overflow Checks
The previous code checked for signed overflow on +, -, and * by doing
the operation and checking the result, which can invoke undefined
behavior. This replaces that code with initial tests on the operands.

In addition, a test for the sole integer division overflow case (that
is not division by zero) was missing: INT_MIN / -1
It has now been added, along with a test case.
2024-06-25 15:00:02 -07:00
Jeff Trull
543a0e9e1d Restore previous newline output after pragma (#201)
This line was inadvertently removed in 1.84 as part of another bug
fix. This change restores it and improves the associated unit test.
2024-01-17 19:09:53 -08:00
Jeff Trull
28ff870cc5 Support a single #pragma without body
The existing code assumed there was at least one space following
 #pragma, but that is not required.
2023-10-23 20:07:47 -07:00
Jeff Trull
f10ee1fc3d Add test for \e \E feature overlooked in prior commit 2022-11-08 18:13:32 -08:00
Jeff Trull
68b8e26625 Fix line directives after endif following else (#170)
* Fix line directives after endif when else clause is present

The initial part of a conditional block (the if/ifdef/ifndef) takes
the "slow" path through the code in cpp_iterator.hpp using the C++
expression grammar, while else and endif directives take the "fast"
path. The slow path sets must_emit_line_directive, and it will be
cleared after either else or endif is processed. Unfortunately when
an else precedes the endif, must_emit_line_directive is cleared and is
never set, as only the slow path sets it. The result is proper line
directives are issued for the else clause, but not for the subsequent
endif.

This changes adds setting of must_emit_line_directive in the "fast"
path for endif so line directives are considered after an intervening else.
2022-06-25 07:09:56 -07:00
Jeff Trull
44e3f30ff9 Let long integer literals participate in conditional expressions (#165)
Also add a test case for this situation
2022-06-22 11:23:06 -07:00
Jeff Trull
977b67a1d0 Fix missing (uncalled) exception hooks (#166)
* Check hooks after expected errors, not just when there are none

Some unit tests had intentional errors, and code to verify that the
appropriate hooks were called, but we never checked.

* Update unit tests to match hooks, now that we are checking

* Fix bug revealed by checking the hooks

Or in other words, bug #161 (thanks abakhirkin for the fix)

* Fix link in documentation
2022-06-22 11:22:27 -07:00
Jeff Trull
59610d6f79 Extend __has_include() grammar for arbitrary conditional expressions (#144)
* Extend __has_include grammar for complex conditional expressions

The logic handling __has_include erroneously assumed it would always
be the last expression on a line. This code fixes that by extending
the grammar to only consume the __has_include() itself, and count
parentheses as necessary to find the correct input range.

Also add some unit tests to cover the error in the future.

* While I'm at it, a couple of small cleanups

1) Remove unneeded header
2) The wrong BOOST_SPIRIT_DEBUG_TRACE_RULE was commented out
2022-01-18 10:46:16 -08:00
Jeff Trull
467afcc46e Qualify "newline at EOF not required" with actually being there (#141)
In C++11 and later modes Wave by default does not require newline prior to EOF. This works
fine but there is one place where the test for this feature was used but Wave is not necessarily
looking at the end of the file: pp_is_last_on_line. One observable (and surprising)
result is that unknown directives are not getting flagged - there may be others. The unit tests
did not discover this problem because they generally do not set c++11 mode.

The necessary qualification is added, along with unit test to cover this issue.
2022-01-02 14:24:39 -08:00
Jeff Trull
9d68ca319a Track the location tokens were expanded from, for __LINE__ and __FILE__
An (optional) extra position field is added to token_data and set for
any identifier token created from a macro expansion. This information
is used to correctly calculate the filename and line number.
2020-07-20 20:51:14 -07:00
Jeff Trull
ee0a7c14c5 Implement __has_include() (#102)
Resolve #96 by introducing C++17 feature (and frequent vendor extension) __has_include(), along with appropriate unit tests and documentation updates
2020-06-27 07:22:52 -07:00
Jeff Trull
3b6df8adb1 Include __LINE__, __FILE__, __INCLUDE_LEVEL__, and __VA_OPT__ in hooks (#87)
* Run hooks for certain predefined object-like macros

These are the "dynamic" macros with their own special execution path.
Most predefined macros can be computed at startup time; those were
already covered by the normal expansion code.

*  __VA_OPT__ is supported as a function-like macro

It is referred to as such in the proposal. __VA_ARGS__ is not supported, under the theory that it represents a parameter or set of parameters, and no hooks are called for parameter substitutions.
2020-04-12 12:40:03 -07:00
Jeff Trull
b68940a83b Disallow mixed-case long long integer literals (#80)
- Update all four lexers to allow ll/LL but not lL/Ll
- Add unit tests for checking
- Remove invalid token from test
2020-03-15 22:54:01 -07:00
Jeff Trull
ec0c8c8603 Implement C++20 features (#75)
* Introduce support for C++20 preprocessor features

- add __VA_OPT__ feature to variadic macros
- allow supplying 0 variadic arguments in more cases
- add related unit tests
2020-03-06 11:48:50 -08:00
Robert Lenhardt
e3680846ce fix utf8 testcases on non-windows systems 2018-10-06 12:41:23 +02:00
Robert Lenhardt
231aad085f add tests for utf-8 paths 2018-10-04 17:40:21 +02:00
Jeff Trull
c74492a208 Remove inadvertent newline from end of test file
Also tweak generated file to reflect source and avoid future speed bumps
2017-11-28 05:37:16 -08:00
Jeff Trull
1fde04d215 Repair C++11 raw string literal lexing, support custom delimiters, add tests 2017-11-27 19:26:11 -08:00
Hartmut Kaiser
10110a16b9 Fixing failing test on systems where BOOST_WAVE_SUPPORT_MS_EXTENSIONS is not defined 2017-10-19 16:23:19 -05:00
Abel Sinkovics
358a0e9668 Fix including header file without newline at the end 2017-09-18 22:25:52 +02:00
Abel Sinkovics
972461234d Fix reporting missing #endif when there is no new line after #if or #else 2017-09-18 22:02:57 +02:00
Abel Sinkovics
a53b51e440 Fix #line directive without new line at the end of a file 2017-09-17 15:35:37 +02:00
Abel Sinkovics
3c8b90bf60 Accept files with preprocessor directive in last line and no new line in C++11 mode. 2017-09-17 13:49:36 +02:00
Abel Sinkovics
4c4cc7e2ff Don't emit a warning about missing new line at end of file in C++11 mode 2017-09-16 22:49:30 +02:00
Hartmut Kaiser
7dcb53aa80 Wave: fixed #8848: Wave driver improperly processes 0xFFFFui64 token
[SVN r85077]
2013-07-19 01:49:48 +00:00
Hartmut Kaiser
f83599b75b Wave: Fixed an obscure problem when preprocessing directives wouldn't be recognized if the previous line contained nothing but an empty macro invocation (see new test case t_9_023.cpp)
[SVN r79783]
2012-07-28 14:08:09 +00:00
Hartmut Kaiser
acb22f3fec Wave: reverting accidental commit
[SVN r79687]
2012-07-23 00:15:20 +00:00
Hartmut Kaiser
f441ea8aed Wave: Changed --c++0x command line option to --c++11.
[SVN r79685]
2012-07-22 23:12:11 +00:00
Hartmut Kaiser
56f4a8e7d2 Fixed #7159: Text-lines are processed as if they were preprocessing directives
[SVN r79684]
2012-07-22 23:08:25 +00:00
Hartmut Kaiser
e5ac1ca3b3 Wave: updating copyrights, minor fixes, bumping version number for release
[SVN r78555]
2012-05-23 14:41:35 +00:00
Hartmut Kaiser
ed79490930 Wave: Fixed #6838: Adding include file with force_include makes Wave fail to emit #line directive
Added support for test of --forceinclude option to testwave executable, added test case verifying #6838 is fixed.

[SVN r78554]
2012-05-23 14:38:10 +00:00
Hartmut Kaiser
5cd2912a6f Wave: Fixed whitespace handling, added a corresponding set of test cases
[SVN r69196]
2011-02-23 01:31:14 +00:00
Hartmut Kaiser
12c91c34c1 Wave: updated copyrights, worked on whitespace skipping
[SVN r67893]
2011-01-09 21:54:54 +00:00
Hartmut Kaiser
0a02b4bc4c Wave: fixed lexing errors introduced with the last commit, added new use case
[SVN r67118]
2010-12-09 03:01:33 +00:00
Hartmut Kaiser
55752997a3 Wave: more work on C++0x support, fixed a macro expansion problem
[SVN r67117]
2010-12-09 01:44:51 +00:00
Hartmut Kaiser
eb2d0881aa Wave: improved consistency in reporting skipped tokens to the hooks function when processing conditional preprocessing directives. Added a new test case verifying the skipped_token hook gets called reproducibly (t_2_020.cpp). Started to work on C++0x features for Wave.
[SVN r65314]
2010-09-05 22:33:20 +00:00
Hartmut Kaiser
1d5a9f46cb Wave: fixing regression test failures
[SVN r61381]
2010-04-18 20:29:54 +00:00
Hartmut Kaiser
1873625de5 Wave : fixing inspection errors
[SVN r61369]
2010-04-18 18:11:55 +00:00
Hartmut Kaiser
ffa289ff67 Wave: adjusting test files for recent bug fixes
[SVN r60829]
2010-03-25 17:41:29 +00:00
Hartmut Kaiser
183f5cae8a Wave: added found_unknown_directive preprocessing hook
[SVN r59537]
2010-02-06 23:23:31 +00:00
Hartmut Kaiser
bbcad7c954 Wave: updating copyrights, fixing issues introduced by latest changes to multi_pass.
[SVN r58714]
2010-01-05 17:29:06 +00:00
Hartmut Kaiser
5146cbbe2a Wave: more work on pragma once pp hooks, added test case
[SVN r56312]
2009-09-19 19:57:09 +00:00
Hartmut Kaiser
4cc8bb6365 Wave: now compiles even with BOOST_FILESYSTEM_NO_DEPRECATED defined
[SVN r51679]
2009-03-10 01:35:54 +00:00
Hartmut Kaiser
a8e6b580db Wave: Updated copyrights
[SVN r50425]
2009-01-01 12:07:12 +00:00
Hartmut Kaiser
3364a7ecc8 Wave: fixed non-ascii characters in source files
[SVN r46800]
2008-06-28 03:20:41 +00:00
Hartmut Kaiser
4b50d02f7a Wave: Changing properties for test.cfg to fix test failures non Windows systems
[SVN r44977]
2008-05-01 16:20:38 +00:00
Hartmut Kaiser
6b02159942 Wave: Updated to use new Spirit Classic library structure and namespace. Lots' of minor changes and adjustments. Switched version to 2.0 since this version is not backwards compatible anymore with earlier versions.
[SVN r44381]
2008-04-13 22:39:12 +00:00