Commit Graph

2382 Commits

Author SHA1 Message Date
Nikita Kniazev
6810f9ecbd Lex: Avoid casting min_token_id to id_type in lexer ctor
When `min_token_id` is not a valid value for `id_type` and `first_id` is not
provided lexer constructor is triggering UB. To fix this problem, constructor
with ommited `first_id` initializes `next_token_id` directly, so if unique ids
feature is not used there is no UB.
2018-11-20 23:59:45 +03:00
Nikita Kniazev
cfcfe6d0cd
Merge pull request #418 from Kojoley/simplify-symbols
Simplify symbols
2018-11-19 19:32:51 +03:00
Nikita Kniazev
2a80c25584 Simplify symbols 2018-11-16 19:35:49 +03:00
Romain Geissler
5e10e84031 Prepare for C++20 and remove "throw()" usage. 2018-11-11 23:14:05 +00:00
Nikita Kniazev
ff6a8e4e13 [1.69] Version bump and changelog update [skip ci] 2018-11-08 18:06:37 +03:00
Nikita Kniazev
3fbde9c195 to_utf8: Fixed wchar_t handling on Windows
Spirit were assuming that wchar_t is 32-bit and the content is UCS-4.
It is wrong, the actual representation is implementation defined [lex.ccon]/6.
However, on most Unix platforms this assumption is valid and gives the
expected outcome, but on Windows wchar_t is 16-bit and the content is UTF-16.
2018-10-28 17:43:05 +03:00
Nikita Kniazev
4be6e2d033
Merge pull request #410 from Kojoley/fix-buffer-char-type-on-windows
Karma: Fixed wrong buffer char type on Windows
2018-10-25 13:55:00 +03:00
Nikita Kniazev
4b1b2dfd2d Karma: Fixed wrong buffer char type on Windows
With `BOOST_SPIRIT_UNICODE` defined Clang, MinGW and Cygwin were using `wchar_t`.

I have switched to OS detection with `_WIN32`, it will give the right results for
most compilers except Cygwin.
2018-10-24 16:53:10 +03:00
Nikita Kniazev
ea9c54ab0e
Merge pull request #407 from Kojoley/qi-transform_attribute-adapt_adt-specialization-ambiguity
V2: Fixed transform_attribute ambiguity
2018-10-23 05:10:47 +03:00
Nikita Kniazev
5c62f8baf3 V2: Fixed transform_attribute ambiguity
Domain-agnostic class template partial specializations and
type agnostic domain partial specializations are ambious.
To resolve the ambiguity type agnostic domain partial
specializations are dispatched via intermediate type.
2018-10-22 01:19:27 +03:00
Nikita Kniazev
bfbd691c4f Missing visibility mark on exception types
https://gcc.gnu.org/wiki/Visibility#Problems_with_C.2B-.2B-_exceptions_.28please_read.21.29
2018-10-17 22:09:19 +03:00
Nikita Kniazev
72c8da1099 Classic: utility/loops.hpp: Added missing includes 2018-09-26 15:41:09 +03:00
Nikita Kniazev
b3ae790e2b Use endian macros from Predef
The `boost/detail/endian.hpp` header is deprecated.
2018-09-15 18:19:49 +03:00
Nikita Kniazev
925f40a2d0
Karma: Missing include for math::fpclassify 2018-08-17 00:59:08 +03:00
Nikita Kniazev
43f8b5035e Drop own fp routines in favor of boost::math
Remove own fp routines as Boost 1.40 released ~9 years ago.
The `boost::math::changesign` usage fixes trac 13531.
2018-07-27 20:26:11 +03:00
Nikita Kniazev
e2c3a539ad Misstyped version digit [skip ci] 2018-07-01 19:45:03 +03:00
Nikita Kniazev
2d1b8eb95d Bump version and update changelog [skip ci] 2018-07-01 19:32:50 +03:00
Nikita Kniazev
bbfa94974d
Merge pull request #379 from RandomInEqualities/develop
X3: variant: More fixes for compilation with VS2015 Update 3
2018-07-01 01:31:12 +03:00
Christian Andersen
27c2fb5a53 X3: variant: More fixes for compilation with VS2015 Update 3
This applies the fix in 6d6f40c3e5 to all BOOST_NOEXCEPT_IF statements in
variant.cpp. I have trouple compiling a toy project with VS2015, as these
noexcept if statements fails to compile.
2018-06-30 16:37:52 +03:00
Nikita Kniazev
cfe94349e2 Classic: The right fix for PR 336 2018-04-17 19:04:51 +03:00
sehe
4196998377 Specialize iterator_source for random access
Optimizing this case allows the compiler to achieve a large speedup
especially in the case where the underlying range is contiguous in
memory.

The effective result is for the performance to be equivalent to directly
using `boost::iostreams::array_source<char_type>` if the source range so
allows.

This patch arose from benchmarking several varying approaches to parsing
posix timestamps here:

 - https://stackoverflow.com/questions/49693376/why-does-using-a-stream-in-boost-spirit-penalize-performance-so-much
 - https://stackoverflow.com/questions/49671674/use-a-trait-for-parsing-a-date-in-boostspirit

I'll refer to that location for some benchmark results.
2018-04-08 13:35:44 +02:00
Nikita Kniazev
ae78e1ec24 X3: sequence: Fixed reference to temporary bug 2018-03-16 20:10:37 +03:00
Nikita Kniazev
e7f31017ec Qi: Fixed ADT support by permutation and sequence_or operator
This is follow-up to 0f2b3c49ce
2018-03-16 01:23:31 +03:00
Nikita Kniazev
1d9aa696bf Karma: Fixed use after scope bug if ADT getter returns by value
The `extract_from_attribute` returns a reference to a temporary
value produced by calling Fusion ADT adapted sequence getter that
returns by value.

Was reported 6 years ago https://svn.boost.org/trac10/ticket/6126
2018-03-15 18:50:17 +03:00
Nikita Kniazev
4213d53d9a X3: More fine grained sequence attribute check message 2018-03-14 15:41:01 +03:00
Nikita Kniazev
b22686b7d7
Qi: skip_over: Remove redundant check
End iterator check is redundant here because it is done in skipper.

Follow-up to PR #373.
2018-03-12 18:25:11 +03:00
Nikita Kniazev
bfec8c66f9 X3: skip_over: Remove redundant check
End iterator check is redundant here because it is done in skipper.
2018-03-11 17:38:51 +03:00
Nikita Kniazev
fac9dfae9e X3: Pass container attribute through sequence 2018-02-28 23:21:31 +03:00
Nikita Kniazev
f73b121a83
Merge pull request #246 from ecatmur/ubsan-abs-negation-in-unsigned
Karma: Perform negation in unsigned type to prevent UB
2018-02-24 17:57:26 +03:00
Nikita Kniazev
a1e9668c34
Merge pull request #368 from Kojoley/small-list-parser-optimization
Small list parser optimization
2018-02-24 05:01:07 +03:00
Nikita Kniazev
b0e8095a94 Suppress MSVC C4146 warning 2018-02-24 04:55:05 +03:00
Nikita Kniazev
42e1d4989b X3: Small list parser optimization 2018-02-23 23:09:34 +03:00
Nikita Kniazev
b9ac3e4a23 Added comment of implementation limitations 2018-02-23 22:42:54 +03:00
Nikita Kniazev
c7f2b86118 Removed redundant static_cast 2018-02-23 22:32:17 +03:00
Nikita Kniazev
0831d603e4 Classic: parser_names.ipp: Fixed unused parameter warnings 2018-02-22 20:49:20 +03:00
djowel
d98a785093 Merge branch 'Some-Tutorials' into develop 2018-02-21 10:50:07 +08:00
Nikita Kniazev
f324a80d83 Bump version and update changelog [skip ci] 2018-02-20 21:14:37 +03:00
Nikita Kniazev
8a29b4c574 Added missing copy assignment operator
Closes trac #8268
2018-02-18 03:10:45 +03:00
Nikita Kniazev
37bcfced65
Merge pull request #358 from Kojoley/add-some-asserts-to-real-parsers
Added some asserts to real parsers
2018-02-15 21:36:19 +03:00
Nikita Kniazev
7ba702ff8f Added some asserts to real parsers
Should prevent static analyzer false-positives.
2018-02-14 19:48:38 +03:00
Tim Angus
3d04ba605f Use traits to detect test container is empty 2018-01-24 17:27:51 +00:00
Marc Gallagher
ea57c257f6 Prevent parse_nan() from dereferencing out of range iterator 2018-01-04 15:29:32 -08:00
Nikita Kniazev
54d5ea1ea8
Merge pull request #345 from DanielaE/fix/no-iterator-inheritance
Inheriting std::iterator is deprecated in c++17
2018-01-01 19:49:28 +03:00
Nikita Kniazev
1433de2fe3 X3: Remove unused function_types includes 2017-12-30 20:52:38 +03:00
Daniela Engert
8edbebe8b3
Inheriting std::iterator is deprecated in c++17
Boost's iterator.hpp is deprecated, too. It does nothing but pulling std::iterator into namespace boost and including standard headers 'iterator' and 'cstddef'. Therefore get rid of all of that and replace inheritance by lifting std::iterator's members into the derived class.
2017-12-29 19:35:56 +01:00
Nikita Kniazev
681db787d8
X3: expect: Fix multiple specializations match
.\boost/spirit/home/x3/core/detail/parse_into_container.hpp(299): error C2752: 'boost::spirit::x3::detail::parse_into_container_impl<Parser,Context,RContext,void>': more than one partial specialization matches the template argument list
2017-12-23 03:43:53 +03:00
Nikita Kniazev
3ae9e29184
Merge pull request #152 from vogelsgesang/fix_expect_container_parsing
X3: Fix expect directive's handling of container attributes
2017-12-23 03:12:39 +03:00
Nikita Kniazev
5bd4d10619 X3: Dereference a single item view instead of unwrapping sequence
A single item sequences like `fusion::vector<T>` will be passed through,
while fusion iterators, fusion iterator range or view of size one will
be dereferenced before passing to underlying parsers of sequence parser.
2017-12-22 18:08:39 +03:00
Nikita Kniazev
6cd3d3a08f fix sequence partitioning problem (reverted from commit a8e391bd99) 2017-12-22 18:02:47 +03:00
Nikita Kniazev
12c79e2b2e Classic: Increment scanner through iterator policy
Closes https://svn.boost.org/trac10/ticket/7371

The trac ticket author was right and left unnoticed for 5 years.
2017-12-21 02:53:07 +03:00
Nikita Kniazev
9bdbf6bd2b X3: Fixed iterator move_to to single item sequence
This affects lazy attribute constructing parsers, which exposes not an actual
attribute, but a pair of iterators (like `string` or `attr("...")`).
2017-12-21 01:55:51 +03:00
Nikita Kniazev
fa771b62d6
Merge pull request #330 from Kojoley/x3-reenable-fusion_map-support
X3: Reenable fusion::map support
2017-12-18 18:51:48 +03:00
Nikita Kniazev
62d604603c
Merge pull request #331 from Kojoley/boost-foreach
Remove unused `boost/foreach.hpp` includes
2017-12-18 18:51:32 +03:00
Nikita Kniazev
b24f0ca9c9
Merge pull request #335 from Kojoley/classic-unused-parameter-warnings
Classic: Fixed unused parameter warnings
2017-12-18 18:49:15 +03:00
Mike Gresens
9a562de232
Merge pull request #328 from octopus-prime/fix_for_trac_5983
Stack overflow with Karma floating point generator
2017-12-18 12:03:25 +01:00
Nikita Kniazev
da4f1ed122 Classic: Fixed unused parameter warnings 2017-12-18 02:21:28 +03:00
Nikita Kniazev
11a36a0ce2 Remove unused boost/foreach.hpp includes 2017-12-17 20:14:56 +03:00
Nikita Kniazev
5b061a1130 Qi.Repository: Some header moving between keywords and kwd 2017-12-17 20:14:56 +03:00
Nikita Kniazev
9954b8467b Qi: permutation: Use array::fill instead of BOOST_FOREACH loop 2017-12-17 04:25:05 +03:00
Nikita Kniazev
c5411ad237 X3: Reenable fusion::map support
`build_container<char>` specialization was added in 84c0c075 (#5)
2017-12-17 01:02:27 +03:00
Nikita Kniazev
60c971df52 Karma: Fix truncation warning if attribute is wider than binded value
Actually the warning here is a sign of bad design. Attribute should go directly
to sink, and there will be no truncation warning except a situation when sink
is not wide enough for attribute or binded value.
2017-12-16 22:11:37 +03:00
Mike Gresens
60031eb779 Fix container traits for msvc (#318)
- Fixes #298 and is based on 45902cbb4e provided by @Kojoley 
- Added container_support.cpp to x3 test suite again
2017-12-16 22:10:00 +03:00
Nikita Kniazev
20a63aa976
Merge pull request #324 from Kojoley/lex-generated-lexer-newline_in_constant
Lex: Fixed C2001 'newline in constant' warning in generated lexers
2017-12-15 16:21:30 +03:00
octopus-prime
26c782c229 Replaced tabs by spaces 2017-12-15 11:44:51 +01:00
octopus-prime
6a4547ca43 Added fix and test from trac # 5983 2017-12-15 11:29:46 +01:00
Nikita Kniazev
3d6f2c9bce Lex: Fixed C2001 'newline in constant' warning in generated lexers
Closes https://svn.boost.org/trac10/ticket/11540.

Actually this should have been caught by `regression_matlib_generate_switch`
test, but it is not complex enough to cover all cases. We do not have the
coverage reports yet, but the fix is trivial so I think it is ok.
2017-12-14 21:53:27 +03:00
Nikita Kniazev
2d7dcd9f6e Classic: Fix compilation with BOOST_DISABLE_THREADS defined
Closes https://svn.boost.org/trac10/ticket/12639
2017-12-14 21:26:53 +03:00
Joel de Guzman
b10e4a477b
Merge pull request #320 from think-cell/thinkcell_iterator_check
ForwardIterator -> ReadableIteratorConcept & ForwardTraversalConcept
2017-12-11 08:02:09 +08:00
djowel
6de1792825 If there's ambiguity in attribute_category on container_attribute or tuple_attribute (e.g. array and std::array), choose tuple_attribute. We probably should define is_container better. 2017-12-09 11:26:37 +08:00
Nikita Kniazev
d3cbd18af4
Merge pull request #310 from Kojoley/sequential_or-random-order-bug
sequential_or: Fixed random order execution of underlying parsers
2017-12-08 19:48:23 +03:00
Nikita Kniazev
109253ac8c
Merge pull request #319 from Kojoley/fix-qi-permutations-always-initializes-optionals
Qi: Permutations parser always initializes optionals
2017-12-08 19:46:40 +03:00
Han Wang
766cc4c9b7 ForwardIterator -> ReadableIteratorConcept & ForwardTraversalConcept
The concept of ForwardIterator is flawed because it mixed 2 sets of concepts (value access and traversal) into 1 package.

http://www.boost.org/doc/libs/1_65_1/libs/iterator/doc/new-iter-concepts.html

It requires value_type (const)& as return type when dereference is applied, which is not mandatory in spirit parsing. A return type which is convertible to value_type is good enough. ReadableIteratorConcept and ForwardTraversalConcept should be what we need for the iterator check.

For example, the iterator of the range returned by boost::adaptors::transform(std::string, func) is normally not a ForwardIterator. But it fulfills ReadableIteratorConcept and ForwardTraversalConcept and should be able to be parsed by spirit.
2017-12-07 17:25:37 +01:00
Nikita Kniazev
3f18a6e99f Qi: Permutations parser always initializes optionals
Closes https://svn.boost.org/trac10/ticket/12473

Optional parser never fails so `attr = val;` always triggers and initializes
the `attr` value. The special case for optional attributes could be safely
removed as any underlying parser must already correctly handle optionals.
2017-12-07 17:59:04 +03:00
octopus-prime
52de6d17ba Fix for trac ticket 12928 "x3 cannot synthesize attribute of type
boost::iterator_range in a sequence parser"
2017-12-06 19:19:08 +01:00
Nikita Kniazev
6e329cbf45
Merge pull request #313 from Kojoley/fix-include-guard-names-collision
X3: Fixed include guard names collision
2017-12-06 13:51:53 +03:00
Nikita Kniazev
d58e26ed73 Karma: attr_cast: Wrong BOOST_SPIRIT_NO_PREDEFINED_TERMINALS ifndef 2017-12-05 21:31:54 +03:00
Nikita Kniazev
1c48ce8d1a Qi.Repository: advance: Add missing include 2017-12-05 20:40:14 +03:00
Nikita Kniazev
4d8ce7024d Qi.Repository: keywords: Added missing include 2017-12-05 20:40:14 +03:00
Nikita Kniazev
332d267d67 Qi.Repository: kwd: Added missing include 2017-12-05 20:40:14 +03:00
Nikita Kniazev
d0d9f67407 Repository: Fix compilation with BOOST_SPIRIT_NO_PREDEFINED_TERMINALS 2017-12-05 17:57:40 +03:00
Nikita Kniazev
cb946ba083 X3: Fixed include guard names collision 2017-12-05 17:01:05 +03:00
Nikita Kniazev
6a37fde4ca sequential_or: Fixed random order execution of underlying parsers
After two hours of fighting with the optimizer, I happily drew attention to
this little nifty bitwise operator in `any_if_ns` function.

Explanation of the bug: bitwise inclusive OR operator is not a sequence point
(per chapter §5.13 of C++14 standard), that's why at compiling the expression
`a() | b() | ... | z()` optimizer is allowed to rearrange the execution order
of the functions `a`, `b` ... `z`.

There is high chance that a lot of people were misguided by the bug and chose
not to use `sequential_or`.

I vaguely remember how about three years ago I thought that I am dumb and/or
the documentation is wrong when I tried to use the `sequential_or` but ended
with some workaround.

There are three possible fixes:
  - This one
  - Make the original `any_ns` and `any_if_ns` strict ordered
    (could potentially make permutations operator slower)
  - Break the `any_ns` and `any_if_ns` API and somehow generalize the code
2017-12-04 18:28:50 +03:00
Mike Gresens
b476a28af7
Merge pull request #304 from octopus-prime/line_pos_iterator_fix3
Line pos iterator fix3
2017-12-04 14:01:50 +01:00
Mike Gresens
5ec71cfd33
Merge pull request #307 from octopus-prime/optional_attribute
optional_attribute
2017-12-04 11:37:51 +01:00
Nikita Kniazev
1265ee169c
Merge pull request #120 from mlang/x3/implicit
X3: Make use of implicit constructibility.
2017-12-03 15:45:05 +03:00
Nikita Kniazev
deab0a2613
Merge pull request #109 from mlang/x3/repeat-kleene-auto
auto makes this simpler.
2017-12-03 15:25:36 +03:00
Nikita Kniazev
6d6f40c3e5 X3: Workaround VS2015 rvalue ref in template of noexcept expression bug
error C2057: expected constant expression
2017-12-02 18:20:07 +03:00
Nikita Kniazev
a30e517b1e X3: Workaround VS2015 decltype in function arguments bug
Thanks @hia3 for the c51a01 workaround.
2017-12-02 18:20:02 +03:00
octopus-prime
c3a83ce083 optional_attribute 2017-12-01 19:10:20 +01:00
octopus-prime
0dd6e531c8 Cleaned up 2017-12-01 15:05:44 +01:00
octopus-prime
646bce6ce7 Merged and added more tests. 2017-12-01 13:04:36 +01:00
Nikita Kniazev
9fc87a8d21
Merge pull request #297 from think-cell/thinkcell_uint_parser_overflow
fix uint_parser<T(signed)> overflow problem
2017-12-01 13:43:43 +03:00
Nikita Kniazev
c40e6742a0
Merge pull request #303 from Kojoley/fix-classic-file_iterator-truncation-warning
Classic: file_iterator.ipp: Fixed truncation warning
2017-12-01 13:43:00 +03:00
Nikita Kniazev
80414bc688 fix qi::uint_parser<T(signed)> overflow problem 2017-12-01 03:36:33 +03:00
Nikita Kniazev
59f9648a54 Classic: file_iterator.ipp: Fixed truncation warning 2017-12-01 03:22:19 +03:00
Nikita Kniazev
7422ab0682
Merge pull request #252 from jeking3/ignore-unused
silence coverity discovery of ignored return code from at_end
2017-11-30 03:58:24 +03:00
Han Wang
b8b82630ac fix x3::uint_parser<T(signed)> overflow problem
According to spirit document,

  "All numeric parsers check for overflow conditions based on the type T the corresponding uint_parser<> has been instantiated with. If the parsed number overflows this type the parsing fails. Please be aware that the overflow check is not based on the type of the supplied attribute but solely depends on the template parameter T."

the valid input range of x3::uint_parser<T> should be 0 - std::numeric_limits<T>::max(). However, the current implementation takes values from std::numeric_limits<T>::max()+1 - std::numeric_limits<std::make_unsigned_t<T>>::max() also as valid input.
2017-11-27 17:47:10 +01:00
octopus-prime
6908307132 Replaced tab by spaces. 2017-11-23 15:40:21 +01:00
octopus-prime
74f67517c3 Bugfix and tests for issue #287 "x3 cannot parse into associative
containers anymore".
2017-11-23 15:26:28 +01:00
Hartmut Kaiser
0854b45b6a Fix scary warning in hold_any 2017-11-22 09:58:47 -06:00
Joel de Guzman
2a6e8f73ed
Merge pull request #284 from Kojoley/fix-subrule-use-after-scope
subrule: Fixed a huge use after scope bug
2017-11-22 07:26:42 +08:00
Nikita Kniazev
f67fcd0e95 Fixed nested comment is not allowed warning from intel compiler 2017-11-21 19:49:38 +03:00
Nikita Kniazev
fdb56edbc8 Classic: Fixed forcing value to bool warning
The warning even removed from MSVC 2017
2017-11-21 19:49:37 +03:00
Nikita Kniazev
4e700fe285 Qi: stream: Fixed truncation warning 2017-11-21 19:49:37 +03:00
Nikita Kniazev
d3cc71002c Fixed redundant semicolons 2017-11-21 19:49:37 +03:00
Nikita Kniazev
34e078d11e Classic: switch: Fixed right_t typedef shadowing 2017-11-21 19:49:37 +03:00
Nikita Kniazev
7f012982e2 Classic.Phoenix: composite: Fixed placesholder names shadowing
Could be triggered if one uses `using namespace phoenix`.
2017-11-21 19:49:36 +03:00
Nikita Kniazev
138b055a1d Classic: escape_char: Suppress conditional expression is constant warning
`boost/spirit/home/classic/utility/impl/escape_char.ipp(143): warning C4127: conditional expression is constant`
2017-11-21 19:49:36 +03:00
Nikita Kniazev
9bf993abfa Classic: Fixed iter_policy_t and scanner_policies_t shadowing problem
`iter_policy_t` and `scanner_policies_t` declared at Spirit's namespace scope.
2017-11-21 19:49:36 +03:00
Nikita Kniazev
8f6a9aaaa3 Classic: file_iterator: Fixed 'size_t' to 'long' conversion warning 2017-11-21 19:49:36 +03:00
Nikita Kniazev
5c44ac5af5 Classic: Fixed unused parameter warnings 2017-11-21 19:49:36 +03:00
Nikita Kniazev
e79f03a062 Qi.Repository: keywords: Fixed unused parameter warnings
```
../boost/spirit/repository/home/qi/directive/kwd.hpp:899:76: warning: unused parameter 'modifiers' [-Wunused-parameter]
../boost/spirit/repository/home/qi/directive/kwd.hpp:922:76: warning: unused parameter 'modifiers' [-Wunused-parameter]
../boost/spirit/repository/home/qi/operator/detail/keywords.hpp:510:35: warning: unused parameter 'first' [-Wunused-parameter]
../boost/spirit/repository/home/qi/operator/detail/keywords.hpp:511:41: warning: unused parameter 'last' [-Wunused-parameter]
../boost/spirit/repository/home/qi/operator/detail/keywords.hpp:512:45: warning: unused parameter 'parse_visitor' [-Wunused-parameter]
../boost/spirit/repository/home/qi/operator/detail/keywords.hpp:513:51: warning: unused parameter 'no_case_parse_visitor' [-Wunused-parameter]
../boost/spirit/repository/home/qi/operator/detail/keywords.hpp:514:40: warning: unused parameter 'skipper' [-Wunused-parameter]
../boost/spirit/repository/home/qi/operator/detail/keywords.hpp:573:92: warning: unused parameter 'position' [-Wunused-parameter]
```
2017-11-21 19:49:35 +03:00
Nikita Kniazev
0773ca38d0 Support: utree_detail2: Fixes sign compare warning 2017-11-21 19:49:35 +03:00
Nikita Kniazev
b174d1f282 subrule: Fixed a huge use after scope bug
It took me 3 days of pulling my hair to debug and fix the bug. The subrule's
author put a big bomb under it and I caught the exposition only in a single
test, with modern versions of Clang/GCC and enabled optimizations (most of
boost regression test runners does not use `variant=release`). Valgrind did
not catch any problems. Enabling address sanitizer causes the bug to disappear
(now I understand why, it places big gaps between stack pointers).
`-fsanitize-address-use-after-scope` catches the bug, but I have discovered
that it is turned off in Clang by default after already having a repro.

The bug could be easily reproduced if you use any parser that invalidates
it's state in the destructor.

I used `literal_char` with added `~literal_char() { ch = char_type(0); }`.

Reproduction code:

```cpp

    rule<char const*> r;
    subrule<0> entry;
    r = (entry = 'a');
    BOOST_TEST(test("a", r));
```

It will fail because after assignment to `r` a temporary `subrule_group` is
destroyed and rule is binded to the already destroyed object.

The cause is in usage of `reference` parser. I am 100% sure the code was
copy-pasted from `rule`/`grammar`. They store an expression within their
body, while `subrule` actually used only as a placeholder.

I have split `subrule_group` into an actual parser/generator that stores the
expression and a Proto terminal that contains the parser/generator.

Tested on:
 - VS 2008, 2010, 2015, 2017
 - Clang 3.8, 3.9, 4.0, 5.0
 - GCC 4.8, 7
2017-11-21 00:37:54 +03:00
Nikita Kniazev
fd10da52b7 Repository: subrule: Fixed partial ordering problem
The problem is that `f(T&)` and `f(T&&)` overloads had the same priority
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1164

Affected compilers are:
 - MSVC 9/10/11
 - GCC 4.7.2, 4.8.4 with `-std=c++1x`
2017-11-15 21:30:32 +03:00
Nikita Kniazev
4ec785d3ed
Merge pull request #271 from Kojoley/fix-alternate
Spirit accidentally relays on `types` typedef of `boost::optional`
2017-11-13 17:21:40 +03:00
Nikita Kniazev
e91aa9f3a2
Merge pull request #259 from Kojoley/fix-subrule
Fix `subrule` compilation
2017-11-13 17:15:57 +03:00
Nikita Kniazev
cdac069504 Classic: Fixed warning from isblank_ with bool scanner
While I do not see usages for `bool` scanner and consider it is a dumb idea
I have not removed the test. Adding the `isblank(bool)` overload seems to me
as a reasonable compromise because it cannot break anything.
2017-11-12 21:17:38 +03:00
Nikita Kniazev
a9e7f574ee Classic: Fixed conversion from 'ptrdiff_t' to 'int', possible loss of data warnings 2017-11-12 17:15:16 +03:00
Nikita Kniazev
99134e9d7b
Merge pull request #275 from Kojoley/fix-classic-boost-optional-has-no-argument_type
Classic: Fixed compilation of `match<T &>`
2017-11-12 17:13:03 +03:00
Nikita Kniazev
632252bafc
Merge pull request #274 from Kojoley/fix-classic-phoenix-actor-remove_reference
Classic: Fix `remove_reference` usage without a namespace
2017-11-12 17:08:32 +03:00
Nikita Kniazev
85fa626071
Merge pull request #273 from Kojoley/fix-classic-phoenix-special_ops-complex
Classic: Fixed `std::complex` usage without the include
2017-11-12 17:07:38 +03:00
Nikita Kniazev
45777098b8 Classic: Fixed compilation of match<T &>
`boost::optional<T &>` has member named `argument_type`

I do not know when it did break because defining
`BOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL`
does not solve the problem.
2017-11-12 03:07:26 +03:00
Nikita Kniazev
41fe4eb5b3 Classic: Fixed unused local typedef in dynamic/for.hpp 2017-11-12 02:50:08 +03:00
Nikita Kniazev
9dac9fb638 Classic: Fixed std::complex usage without the include
08b336d (#195) removed forward declaration but did not add the include.

Closes https://svn.boost.org/trac10/ticket/13240
2017-11-12 02:32:31 +03:00
Nikita Kniazev
ebcedd2523 Classic: Fix remove_reference usage without a namespace 2017-11-12 02:27:10 +03:00
Nikita Kniazev
03b5ab568d Spirit accidentally relays on types typedef of boost::optional
Replaces #201, fixes #249.

New `boost:optional` implementation does not contain `types` what caused
a compilation error for Qi and wrong results for Karma.

Other problem is that `not_is_variant<optional<variant<T...>>>` results in
`mpl::false_` what is unclear from it's name. While Karma relays on exactly
this behavior, Qi wrongly considers that it `mpl::true_`. I have fixed this
name ambiguity and updated Karma for the new `not_is_variant` behavior.
2017-11-10 22:05:10 +03:00
Nikita Kniazev
23531c8ab3
Merge pull request #269 from Kojoley/fix-qi-keywords-unused-parameter-warnings
Qi.Repository: keywords: Fixed unused parameter warnings
2017-11-10 03:37:07 +03:00
Nikita Kniazev
3439373f0c Qi.Repository: keywords: Fixed unused parameter warnings 2017-11-10 03:34:32 +03:00
Nikita Kniazev
1360fdfd16 utree: Fixed possible loss of data warning 2017-11-10 03:33:16 +03:00
Nikita Kniazev
f7049833a1 Revert "Merge pull request #201 from mxc-commons/fix_alternative"
This reverts commit 4c5b976633, reversing
changes made to 0f7b47d33d.
2017-11-10 01:20:33 +03:00
Nikita Kniazev
ee4943d589 X3: Fix unused_type attribute case in parse_into_container
Passing `unused_type` attribute to `parse_into_container_impl::call`
produces a compilation error.

The issue was introduced in 379413a50c.
2017-11-08 19:42:47 +03:00
Nikita Kniazev
688f8c624b Karma: Fixed no_buffering_policy missing copy constructor
It seems that `no_buffering_policy` had a copy-paste error for 8 years.
2017-11-06 20:32:30 +03:00
Nikita Kniazev
025aa31292 Repository: subrule: Fix proto's operators kicks in on c++11 2017-11-03 19:35:19 +03:00
Nikita Kniazev
7240e1fbe7 Repository: subrule: Fix extract_sig usage
With e34a955f2f `extract_sig` changed
but `subrule` did not get an update for that change.
2017-11-03 19:27:50 +03:00
Nikita Kniazev
c240c5ecce Qi.Repository: Fix keywords compilation on c++11 2017-10-31 21:49:12 +03:00
James E. King, III
c744f31222 silence coverity discovery of ignored return code from at_end 2017-10-20 16:44:10 -04:00
Joel de Guzman
5430289e4b Merge pull request #248 from m-dhooge/develop
x3::error_handler::position() CR+LF lines wrongly counted.
2017-10-10 10:43:04 +08:00
Joel de Guzman
1fcefe5bc8 Merge pull request #245 from dtardon/overflow
oss-fuzz: avoid signed integer overflow
2017-10-07 17:08:00 +08:00
mdhooge
79995f7e8f x3::error_handler::position() CR+LF lines wrongly counted. 2017-10-05 09:51:09 +02:00
Edward Catmur
327b725afc Store id as promoted type to allow out-of-enum values 2017-10-03 17:00:13 +01:00
Edward Catmur
c342200867 Perform negation in unsigned type to prevent UB 2017-10-03 16:58:40 +01:00
David Tardon
3d8a80c4f3 ofz#2894 avoid signed integer overflow
/usr/include/boost/spirit/home/qi/numeric/detail/real_impl.hpp:86:48: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
2017-10-02 16:38:11 +02:00
Ed Catmur
26356b5361 Avoid -Wlogical-op error in radix_traits::is_valid
With -Wlogical-op, gcc warns in radix_traits::is_valid with Radix <= 10:

```
boost/spirit/home/qi/numeric/detail/numeric_utils.hpp: In instantiation of ‘static bool boost::spirit::qi::detail::radix_traits<10u>::is_valid<char>(char)’:
[...]
boost/spirit/home/qi/numeric/detail/numeric_utils.hpp:107:31: warning: logical ‘and’ of mutually exclusive tests is always false [-Wlogical-op]
                 || (ch >= 'a' && ch <= static_cast<Char>('a' + Radix -10 -1))
                               ^
boost/spirit/home/qi/numeric/detail/numeric_utils.hpp:108:31: warning: logical ‘and’ of mutually exclusive tests is always false [-Wlogical-op]
                 || (ch >= 'A' && ch <= static_cast<Char>('A' + Radix -10 -1));
                               ^
```

Rather than suppressing the warning (https://github.com/boostorg/spirit/pull/77), refactor the test so that the warning is not triggered.
2017-09-19 18:51:34 +01:00
Adam Merz
b4e4762b6c Add noexcept specs to x3::variant and forward_ast
Add noexcept specifications to X3's variant and forward_ast
2017-08-24 18:05:38 -07:00
Han Wang
19972887f4 Context& -> Context const&
fix parsers like x3::skip(x3::space)[x3::double_] compile problem
2017-08-23 10:45:21 +02:00
Han Wang
30dfb6230a simplify with directive (3): make rvalue injection mutable 2017-08-22 15:43:34 +02:00
Han Wang
361b12eeeb simplify with directive
1. when used as x3::with<ID>(x), where x is an lvalue, we inject an lvalue reference of x to the context.
2. when used as x3::with<ID>(x), where x is a const lvalue, we inject a const lvalue reference of x to the context.
3. when used as x3::with<ID>(x), where x is an rvalue, we move the rvalue to the member of with_directive and inject an lvalue reference of that member to the context.
4. No copy is applied; std::ref is not needed
5. remove unused with_context
2017-08-21 13:48:08 +02:00
Hartmut Kaiser
b187f862b6 Removing use of bind2nd 2017-08-11 04:46:16 -05:00
Joel de Guzman
a476452dbd use boost::swap instead, which does all the namespace stuff. 2017-08-07 11:14:22 +08:00