* 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>
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.
* Update marker before and after fill() operation in cpplexer
* A basic test case for trigraph "pound" (octothorpe) on fill boundary (detects the marker issue)
This change resolves#202
---------
Co-authored-by: Chris Chisolm <chris_chisolm@intuit.com>
Co-authored-by: Jeff Trull <edaskel@att.net>
* Check for backslash characters before the start of the new data
With BOOST_WAVE_BSIZE set to 40, test t_5_002 fails because a newline appears exactly at the beginning of a newly
fetched buffer, and a backslash is at the end of the previous one. In that case the escaped newline
was not detected. This change will also consider three unprocessed bytes of input data, if available,
prior to the new data, which is enough to detect a trigraph backslash.
* Improve data range check for backslash newline
The existing check considered the space required for a trigraph backslash, but not for the following LF (or CRLF) before testing for them. With BOOST_WAVE_BSIZE set to 98 this caused a segfault in t_5_001.
There is no guarantee (indeed, it is unlikely) that data within the
scanner buffer will be null terminated, and so the constructor that
accepts a pointer and a count is appropriate.
This will be for Boost 1.84 forward. The new replacements were
available previously, so for some versions before 1.84 we'll still see
deprecation warnings if users mix versions of Boost and Wave.
Updates the non-strict lexer to support e and E, both with value 27
(ASCII ESC). Also adds tests for lexing these literals, and checks
that they are usable in conditional preprocessor expressions.
* 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.
* 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
* Use capacity() == 0 as the definitive mark of an empty string storage.
Comparing the pointer with the static emptyString_ member of the
SimpleStringStorage class will likely break if the comparison happens
across shared library boundary. So use capacity() == 0 consistently
to detect whether the storage refers to the emptyString_ member.
When capacity is non-zero the data is always dynamically allocated.
* Suppress gcc 11.2 -Wfree-nonheap-object warnings.
The warnings are bogus because the pData_ pointer never points to
emptyString_ if capacity() == 0, and always points otherwise. The
compiler simply fails to deduce this invariant.
Unfortunately, suppressing the warning with a #pragma doesn't work,
so we have to invent a compile-time assert that will make the invariant
detectable by the compiler.
Closes https://github.com/boostorg/wave/issues/159.
* Removed unused AllocatorStringStorage::Realloc function.
This function was not used and potentially incorrect, as it unconditionally
calls Free, which would be wrong if the original buffer was emptyString_.
* The comma operator is deprecated inside of square brackets
solution: add parentheses
* Bitwise operations are deprecated between different enum types
solution: add user-defined operators for the combinations we use
* std::tmpnam usage gets a linker warning identifying security issues, recommends mkstemp()
solution: use Boost.Filesystem temporary filename functions
* 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
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.
At some point in the past the handling for #if and #ifdef diverged. The code that handles emitting a line directive when a conditional section is skipped worked for #if but not ifdef/ifndef.
This problem was not observable when the eat_whitespace hooks were used instead of the default_preprocessing hooks, because the former
signals skipped newlines through the may_skip_whitespace hook, hiding the problem. Furthermore, the majority of Wave tests use the eat_whitespace hooks, so it wasn't visible there.
This change restores ifdef/ifndef to the same section as #if, so any changes to conditional handling will happen uniformly. Also, a test case is added to cover the default hooks and this particular case.
These changes, a subset of what clang-format generates, ensure code
and comments are aligned properly for the level of the code. There
were a number of places where comments (many) and code (some) were
four spaces to the left of where they should be. This will make the
code easier to read.
One advantage of separating out these changes is they can be verified
to be whitespace-only with a simple diff.
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.
Reduce build time by:
- using iosfwd instead of iostream, where possible
- where iostream is necessary but only used for debugging,
making its inclusion conditional
- removing old C-style headers
I used IWYU to guide this work
* 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.