Skip to content

Commit 5b6eda2

Browse files
committed
Add add_runtime_support_include to meta
For metafunctions that require runtime support via #includes to be injected into lowered Cpp1 programs Also cleanup while I'm at it: - remove headers from `common.h` that are now already included via `cpp2util.h` - line up some thing that got un-lined-up (OCD)
1 parent 0260d44 commit 5b6eda2

31 files changed

+714
-680
lines changed

include/cpp2util.h

-2
Original file line numberDiff line numberDiff line change
@@ -2813,8 +2813,6 @@ inline constexpr auto as_() -> decltype(auto)
28132813

28142814
}
28152815

2816-
#include "cpp2regex.h"
2817-
28182816
using cpp2::cpp2_new;
28192817

28202818

regression-tests/test-results/gcc-10-c++20/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp.output

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:46: error: expect
66
In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:7:
77
../../../include/cpp2util.h:10005:47: error: static assertion failed: GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.
88
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:4:1: note: in expansion of macro ‘CPP2_REQUIRES_’
9-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: no declaration matches ‘element::element(auto:241&&) requires is_same_v<std::__cxx11::string, typename std::remove_cv<typename std::remove_reference<decltype(element::__ct ::n)>::type>::type>’
9+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: no declaration matches ‘element::element(auto:95&&) requires is_same_v<std::__cxx11::string, typename std::remove_cv<typename std::remove_reference<decltype(element::__ct ::n)>::type>::type>’
1010
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:5:11: note: candidates are: ‘element::element(const element&)’
11-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:20: note: ‘template<class auto:239> element::element(auto:239&&)’
11+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:20: note: ‘template<class auto:93> element::element(auto:93&&)’
1212
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here
1313
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:5:78: error: expected unqualified-id before ‘{’ token
14-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:8: error: no declaration matches ‘element& element::operator=(auto:242&&) requires is_same_v<std::__cxx11::string, typename std::remove_cv<typename std::remove_reference<decltype(element::operator=::n)>::type>::type>’
14+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:8: error: no declaration matches ‘element& element::operator=(auto:96&&) requires is_same_v<std::__cxx11::string, typename std::remove_cv<typename std::remove_reference<decltype(element::operator=::n)>::type>::type>’
1515
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:6:16: note: candidates are: ‘void element::operator=(const element&)’
16-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:16: note: ‘template<class auto:240> element& element::operator=(auto:240&&)’
16+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:16: note: ‘template<class auto:94> element& element::operator=(auto:94&&)’
1717
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here

regression-tests/test-results/gcc-10-c++20/pure2-print.cpp.output

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ pure2-print.cpp2:68:1: note: in expansion of macro ‘CPP2_REQUIRES_’
99
pure2-print.cpp2:97:1: note: in expansion of macro ‘CPP2_REQUIRES_’
1010
pure2-print.cpp2:9:41: error: ‘constexpr const T outer::object_alias’ is not a static data member of ‘class outer’
1111
pure2-print.cpp2:9:48: error: template definition of non-template ‘constexpr const T outer::object_alias’
12-
pure2-print.cpp2:67:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:240& ...) requires (is_convertible_v<typename std::remove_cv<typename std::remove_reference<decltype(outer::mytype::variadic::x)>::type>::type, int> && ...)’
13-
pure2-print.cpp2:67:29: note: candidate is: ‘template<class ... auto:239> static void outer::mytype::variadic(const auto:239& ...)’
12+
pure2-print.cpp2:67:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:94& ...) requires (is_convertible_v<typename std::remove_cv<typename std::remove_reference<decltype(outer::mytype::variadic::x)>::type>::type, int> && ...)’
13+
pure2-print.cpp2:67:29: note: candidate is: ‘template<class ... auto:93> static void outer::mytype::variadic(const auto:93& ...)’
1414
pure2-print.cpp2:10:19: note: ‘class outer::mytype’ defined here
1515
pure2-print.cpp2:96:37: error: no declaration matches ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::impl::cmp_greater_eq(sizeof ... (Args ...), 0)’
1616
pure2-print.cpp2:96:37: note: no functions named ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::impl::cmp_greater_eq(sizeof ... (Args ...), 0)’

regression-tests/test-results/gcc-14-c++2b/gcc-version.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
g++ (GCC) 14.1.1 20240701 (Red Hat 14.1.1-7)
1+
g++ (GCC) 14.2.1 20240801 (Red Hat 14.2.1-1)
22
Copyright (C) 2024 Free Software Foundation, Inc.
33
This is free software; see the source for copying conditions. There is NO
44
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mixed-bounds-safety-with-assert.cpp2(11) void print_subrange(const auto:237&, cpp2::impl::in<int>, cpp2::impl::in<int>) [with auto:237 = std::vector<int>; cpp2::impl::in<int> = const int]: Bounds safety violation
1+
mixed-bounds-safety-with-assert.cpp2(11) void print_subrange(const auto:91&, cpp2::impl::in<int>, cpp2::impl::in<int>) [with auto:91 = std::vector<int>; cpp2::impl::in<int> = const int]: Bounds safety violation

regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.execution

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ Running tests_10_escapes:
99
08_y: OK regex: foo(\h)bar parsed_regex: foo(\h)bar str: foo bar result_expr: $1 expected_results
1010
09_y: OK regex: (\H)(\h) parsed_regex: (\H)(\h) str: foo bar result_expr: $1-$2 expected_results o-
1111
10_y: OK regex: (\h)(\H) parsed_regex: (\h)(\H) str: foo bar result_expr: $1-$2 expected_results -b
12-
11_y: OK regex: foo(\v+)bar parsed_regex: foo(\v+)bar str: foo
12+
11_y: OK regex: foo(\v+)bar parsed_regex: foo(\v+)bar str: foo
13+
1314

15+
bar result_expr: $1 expected_results
16+
1417

15-
bar result_expr: $1 expected_results
1618

19+
12_y: OK regex: (\V+)(\v) parsed_regex: (\V+)(\v) str: foo
20+
1721

22+
bar result_expr: $1-$2 expected_results foo-
23+
13_y: OK regex: (\v+)(\V) parsed_regex: (\v+)(\V) str: foo
24+
1825

19-
12_y: OK regex: (\V+)(\v) parsed_regex: (\V+)(\v) str: foo
20-
21-
22-
bar result_expr: $1-$2 expected_results foo-
23-
13_y: OK regex: (\v+)(\V) parsed_regex: (\v+)(\V) str: foo
24-
25-
26-
bar result_expr: $1-$2 expected_results
27-
26+
bar result_expr: $1-$2 expected_results
27+
2828

2929
-b
30-
14_y: OK regex: foo(\v)bar parsed_regex: foo(\v)bar str: foobar result_expr: $1 expected_results
31-
15_y: OK regex: (\V)(\v) parsed_regex: (\V)(\v) str: foobar result_expr: $1-$2 expected_results o-
30+
14_y: OK regex: foo(\v)bar parsed_regex: foo(\v)bar str: foobar result_expr: $1 expected_results
31+
15_y: OK regex: (\V)(\v) parsed_regex: (\V)(\v) str: foobar result_expr: $1-$2 expected_results o-
3232
16_y: OK regex: (\v)(\V) parsed_regex: (\v)(\V) str: foobar result_expr: $1-$2 expected_results -b
3333
17_y: OK regex: foo\t\n\r\f\a\ebar parsed_regex: foo\t\n\r\f\a\ebar str: foo
3434
bar result_expr: $& expected_results foo

regression-tests/test-results/pure2-regex_01_char_matcher.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_02_ranges.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_03_wildcard.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_04_start_end.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_05_classes.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_06_boundaries.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_07_short_classes.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_08_alternatives.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_09_groups.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_10_escapes.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_11_group_references.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_12_case_insensitive.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_13_possessive_modifier.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_14_multiline_modifier.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_15_group_modifiers.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_16_perl_syntax_modifier.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_17_comments.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_18_branch_reset.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

regression-tests/test-results/pure2-regex_19_lookahead.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
#define CPP2_IMPORT_STD Yes
3+
#include "cpp2regex.h"
34

45
//=== Cpp2 type declarations ====================================================
56

source/common.h

-9
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,11 @@
3838
#ifndef CPP2_COMMON_H
3939
#define CPP2_COMMON_H
4040

41-
#include <algorithm>
4241
#include <cassert>
4342
#include <cctype>
4443
#include <chrono>
45-
#include <compare>
46-
#include <cstdint>
4744
#include <iomanip>
48-
#include <iterator>
49-
#include <memory>
50-
#include <map>
51-
#include <string>
52-
#include <string_view>
5345
#include <unordered_map>
54-
#include <vector>
5546

5647
namespace cpp2 {
5748

source/parse.h

+10-4
Original file line numberDiff line numberDiff line change
@@ -5532,6 +5532,7 @@ auto pretty_print_visualize(translation_unit_node const& n)
55325532
class parser
55335533
{
55345534
std::vector<error_entry>& errors;
5535+
std::set<std::string>& includes;
55355536

55365537
std::unique_ptr<translation_unit_node> parse_tree = {};
55375538

@@ -5577,10 +5578,10 @@ class parser
55775578
}
55785579
};
55795580

5580-
std::vector<token> const* tokens = {};
5581+
std::vector<token> const* tokens = {};
55815582
stable_vector<token>* generated_tokens = {};
5582-
int pos = 0;
5583-
std::string parse_kind = {};
5583+
int pos = 0;
5584+
std::string parse_kind = {};
55845585

55855586
// Keep track of the function bodies' locations - used to emit comments
55865587
// in the right pass (decide whether it's a comment that belongs with
@@ -5656,13 +5657,18 @@ class parser
56565657
//
56575658
// errors error list
56585659
//
5659-
parser( std::vector<error_entry>& errors_ )
5660+
parser(
5661+
std::vector<error_entry>& errors_,
5662+
std::set<std::string>& includes_
5663+
)
56605664
: errors{ errors_ }
5665+
, includes{ includes_ }
56615666
, parse_tree{std::make_unique<translation_unit_node>()}
56625667
{ }
56635668

56645669
parser( parser const& that )
56655670
: errors{ that.errors }
5671+
, includes{ that.includes }
56665672
, parse_tree{std::make_unique<translation_unit_node>()}
56675673
{ }
56685674

0 commit comments

Comments
 (0)