2
0
mirror of https://github.com/boostorg/wave.git synced 2026-01-24 18:32:38 +00:00
Commit Graph

435 Commits

Author SHA1 Message Date
Alexander Grund
b45951ccb3 Suppress unused parameter warnings 2024-12-10 09:57:13 +01: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
Peter Dimov
f6ffdfe0a3 Avoid inclusion of deprecated header (#227) 2024-09-29 08:37:21 -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
da98931899 Merge pull request #207 from jefftrull/bugfix/ub-signed-overflow
Fix checks for signed overflow
2024-06-25 21:53:44 -07:00
Jeff Trull
7265c575a8 Use vsnprintf instead of vsprintf
Issue noted by MSVC (as a warning)
2024-06-25 16:31:13 -07: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
chisolm
737c1e07ee Update marker before and after fill() operation in cpplexer (#203)
* 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>
2024-01-30 10:16:07 -08:00
Jeff Trull
ff13dee917 Fixes for escaped newline handling (#205)
* 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.
2024-01-29 16:57:04 -08:00
Jeff Trull
f9c302da5b Use correct string constructor for non-null-terminated range (#204)
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.
2024-01-28 18:24:18 -08: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
d8474c3e2d Handle some previously deprecated, now removed, filesystem code
- convenience.hpp is removed
- no_push and branch_path are removed
2024-01-14 15:06:47 -08:00
Jeff Trull
70097dacde Merge pull request #192 from jefftrull/bugfix/filesystem-deprecations
Replace deprecated boost::filesystem methods with their new names
2023-10-25 15:33:07 -07:00
Jeff Trull
a5d4722e52 Replace deprecated boost::filesystem methods with their replacements
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.
2023-10-24 11:39:08 -07: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
Dunfan Lu
0c4ca96c5b Fix UB in memmove 2023-03-27 13:42:45 -04:00
Jeff Trull
3586cf3706 Support \e and \E in character and string literals
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.
2022-11-07 22:44:24 -08:00
DavidCNou
9b05a6b35f Fix potential buffer overflow, fixes boostorg/wave#175 2022-11-07 14:31:35 -05:00
A. Jiang
d1ae14876f Use boost::allocator_max_size to obtain allocator's max_size
Perhaps missed in previous PRs.
2022-09-05 11:00:16 +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
Andrey Semashev
71fb0d8390 Fix warnings about freeing non-heap-allocated object (#163)
* 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_.
2022-06-16 16:02:59 -07:00
Jeff Trull
572f4f644a Clean up C++11 requirements further (#157)
- Test the requirement of "constexpr" for the deprecation error
- Ensure C++11 requirements are checked for the samples build
2022-03-09 14:49:54 -08:00
Jeff Trull
9382ac9e8b MSVC-related cleanups (#150)
* Replace several sprintf's with boost::format or std::to_string
* Clean up MSVC builds by removing pre-C++11 toolsets
* Update build badges
2022-02-20 17:54:26 -08:00
Jeff Trull
1db25211a4 Fix various warnings (#148)
* 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
2022-02-05 15:44:11 -08:00
Jeff Trull
a95fa213ef Clean up sprintf usage (#146)
* Replace some sprintfs using boost::format and std::to_string to fix warnings and possibly #145
2022-01-28 15:04:20 -08: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
f2957045b5 Fix line directives for ifdef and ifndef when default hooks are used (#140)
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.
2022-01-02 07:09:32 -08:00
Jeff Trull
8bc982ba17 Update C++03 removal to 1.79, as window has passed 2021-11-03 22:02:26 -07:00
Jeff Trull
87459418b8 Remove support for C++03 and prior compilers
This removes only support for C++98/03 as a compiler for this library.
Wave continues to support C++98 and C++03 constructs as a preprocessor.
2021-11-03 16:05:59 -07:00
Jeff Trull
88369abfd5 Remove long-deprecated hooks API
Removal in 1.76 was noted in the docs and warned about since 1.74.
2020-12-13 15:53:32 -08:00
Jeff Trull
41ad7916e5 Work around an MSVC bug found in Appveyor run
The error manifests as an "ambiguous symbol" error in optional
2020-10-28 17:41:40 -07:00
Jeff Trull
0ff9eafa04 Add the spaceship <=> operator to the C++20 tokens 2020-10-24 22:01:43 -07:00
Jeff Trull
f1ec8fd22c Make indentation consistent with code nesting
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.
2020-10-23 15:05:00 -07:00
Marshall Clow
1dc69adf1d Remove use of non-existent Boost.Config macro BOOST_NO_CXX11_HDR_MEMORY
Thanks to Jeff Trull for the catch.
2020-09-10 20:12:16 -07:00
Jeff Trull
465fe2291f Merge pull request #109 from jefftrull/feature/cpp20-tokens
Introduce C++20 tokens
2020-08-16 11:55:39 -07:00
Jeff Trull
200f91e71d Introduce C++20 tokens 2020-08-11 13:17:01 -07: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
8536634396 Deprecate C++03 and re-deprecate the old preprocessor hooks (#104)
Targeting a one year transition period for C++03 -> C++11 and one release less to finally get off the old hooks - assuming there are even any users of them.

Also added documentation per @pdimov recommendations at https://pdimov.github.io/articles/phasing_out_cxx03.html#_suggested_policy
2020-06-30 12:24:00 -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
6fd0da8780 Rename include guard macros that don't begin with BOOST_ 2020-06-15 10:52:30 -07:00
Glen Fernandes
5cd3f92597 Simplify allocator use via core/allocator_access 2020-05-26 09:15:34 -04:00
Jeff Trull
895ea836e9 Remove unused headers
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
2020-05-19 10:41:22 -07:00
Jeff Trull
2e8eeeeb4d Add BOOST_OVERRIDE to virtual functions in derived classes (#89) 2020-04-13 21:12:34 -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
016638e6ae Fix more allocator traits (#85)
Finish the process of replacing allocator member types with allocator traits using an approach suggested by @glenfe.
2020-04-10 08:23:10 -07:00
Jeff Trull
e95a01453c Add error checks for a few issues identified by re2c (#82)
- "undefined" input sequences that should in theory never happen
- control characters in C++11 character and string literals
2020-03-18 21:21:59 -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