Skip to content

Commit 5ea5d5c

Browse files
committed
Handle alias declaration before this base, closes #830
And do a round of output formatting cleanup (high diffs)
1 parent 11f2dbb commit 5ea5d5c

File tree

105 files changed

+601
-567
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+601
-567
lines changed
Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
1-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:16:36: error: expected ‘;’ at end of member declaration
2-
16 | public: explicit element(auto&& n)
3-
| ^
4-
| ;
1+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:36: error: expected ‘;’ at end of member declaration
52
In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:7:
63
../../../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.
7-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:17:1: note: in expansion of macro ‘CPP2_REQUIRES_’
8-
17 | CPP2_REQUIRES_ (std::is_same_v<CPP2_TYPEOF(n), std::string>)
9-
| ^~~~~~~~~~~~~~
4+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:4:1: note: in expansion of macro ‘CPP2_REQUIRES_’
105
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:46: error: expected ‘;’ at end of member declaration
116
In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:7:
127
../../../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.
138
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:4:1: note: in expansion of macro ‘CPP2_REQUIRES_’
149
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: no declaration matches ‘element::element(auto:90&&) requires is_same_v<typename std::remove_cv<typename std::remove_reference<decltype(element::__ct ::n)>::type>::type, std::__cxx11::string>’
1510
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:5:11: note: candidates are: ‘element::element(const element&)’
16-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:16:20: note: ‘template<class auto:88> element::element(auto:88&&)’
17-
16 | public: explicit element(auto&& n)
18-
| ^~~~~~~
19-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:14:7: note: ‘class element’ defined here
20-
14 | class element {
21-
| ^~~~~~~
22-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: expected unqualified-id before ‘{’ token
11+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:20: note: ‘template<class auto:88> element::element(auto:88&&)’
12+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here
13+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:5:78: error: expected unqualified-id before ‘{’ token
2314
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:8: error: no declaration matches ‘element& element::operator=(auto:91&&) requires is_same_v<typename std::remove_cv<typename std::remove_reference<decltype(element::operator=::n)>::type>::type, std::__cxx11::string>’
2415
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:6:16: note: candidates are: ‘void element::operator=(const element&)’
2516
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:16: note: ‘template<class auto:89> element& element::operator=(auto:89&&)’
26-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:14:7: note: ‘class element’ defined here
27-
14 | class element {
28-
| ^~~~~~~
17+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ In file included from pure2-print.cpp:7:
77
pure2-print.cpp2:66:1: note: in expansion of macro ‘CPP2_REQUIRES_’
88
../../../include/cpp2util.h:10005:33: error: expected initializer before ‘static_assert’
99
pure2-print.cpp2:94:1: note: in expansion of macro ‘CPP2_REQUIRES_’
10-
pure2-print.cpp2:6:29: error: ‘constexpr const T outer::object_alias’ is not a static data member of ‘class outer’
11-
pure2-print.cpp2:6:36: error: template definition of non-template ‘constexpr const T outer::object_alias’
10+
pure2-print.cpp2:7:41: error: ‘constexpr const T outer::object_alias’ is not a static data member of ‘class outer’
11+
pure2-print.cpp2:7:48: error: template definition of non-template ‘constexpr const T outer::object_alias’
1212
pure2-print.cpp2:65:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:97& ...) requires (is_convertible_v<typename std::remove_cv<typename std::remove_reference<decltype(outer::mytype::variadic::x)>::type>::type, int> && ...)’
1313
pure2-print.cpp2:65:29: note: candidate is: ‘template<class ... auto:88> static void outer::mytype::variadic(const auto:88& ...)’
1414
pure2-print.cpp2:8:19: note: ‘class outer::mytype’ defined here

regression-tests/test-results/mixed-allcpp1-hello.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#line 1 "mixed-allcpp1-hello.cpp2"
2+
#line 1 "mixed-allcpp1-hello.cpp2"
13

24
// Step 1: rename .cpp to .cpp2
35

regression-tests/test-results/mixed-as-for-variant-20-types.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-as-for-variant-20-types.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-as-for-variant-20-types.cpp2"
1214
template<int I>
1315
struct X { operator int() const { return I; } };
1416

1517
#line 4 "mixed-as-for-variant-20-types.cpp2"
1618
[[nodiscard]] auto main() -> int;
1719

18-
1920
//=== Cpp2 function definitions =================================================
2021

22+
#line 1 "mixed-as-for-variant-20-types.cpp2"
2123

2224
#line 4 "mixed-as-for-variant-20-types.cpp2"
2325
[[nodiscard]] auto main() -> int{

regression-tests/test-results/mixed-bounds-check.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-bounds-check.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-bounds-check.cpp2"
1214

1315
#include <vector>
1416

1517
#line 4 "mixed-bounds-check.cpp2"
1618
[[nodiscard]] auto main() -> int;
17-
1819

1920
//=== Cpp2 function definitions =================================================
2021

22+
#line 1 "mixed-bounds-check.cpp2"
2123

2224
#line 4 "mixed-bounds-check.cpp2"
2325
[[nodiscard]] auto main() -> int{

regression-tests/test-results/mixed-bounds-safety-with-assert-2.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-bounds-safety-with-assert-2.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-bounds-safety-with-assert-2.cpp2"
1214

1315
#line 2 "mixed-bounds-safety-with-assert-2.cpp2"
1416
[[nodiscard]] auto main() -> int;
15-
1617

1718
#line 10 "mixed-bounds-safety-with-assert-2.cpp2"
1819
auto add_42_to_subrange(auto& rng, cpp2::in<int> start, cpp2::in<int> end) -> void;
@@ -25,6 +26,7 @@ auto add_42_to_subrange(auto& rng, cpp2::in<int> start, cpp2::in<int> end) -> vo
2526

2627
//=== Cpp2 function definitions =================================================
2728

29+
#line 1 "mixed-bounds-safety-with-assert-2.cpp2"
2830

2931
#line 2 "mixed-bounds-safety-with-assert-2.cpp2"
3032
[[nodiscard]] auto main() -> int{

regression-tests/test-results/mixed-bounds-safety-with-assert.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-bounds-safety-with-assert.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-bounds-safety-with-assert.cpp2"
1214

1315
#line 2 "mixed-bounds-safety-with-assert.cpp2"
1416
[[nodiscard]] auto main() -> int;
15-
1617

1718
#line 9 "mixed-bounds-safety-with-assert.cpp2"
1819
auto print_subrange(auto const& rng, cpp2::in<int> start, cpp2::in<int> end) -> void;
19-
2020
#line 21 "mixed-bounds-safety-with-assert.cpp2"
2121

2222
#include <vector>
@@ -26,6 +26,7 @@ auto print_subrange(auto const& rng, cpp2::in<int> start, cpp2::in<int> end) ->
2626

2727
//=== Cpp2 function definitions =================================================
2828

29+
#line 1 "mixed-bounds-safety-with-assert.cpp2"
2930

3031
#line 2 "mixed-bounds-safety-with-assert.cpp2"
3132
[[nodiscard]] auto main() -> int{

regression-tests/test-results/mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp2"
1214
extern cpp2::i32 x;
1315
int main() { }
1416
// ugh
1517

1618
//=== Cpp2 function definitions =================================================
1719

20+
#line 1 "mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp2"
1821
cpp2::i32 x {0};
1922

regression-tests/test-results/mixed-bugfix-for-literal-as-nttp.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-bugfix-for-literal-as-nttp.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-bugfix-for-literal-as-nttp.cpp2"
1214
#include <chrono>
1315
using namespace std::chrono_literals;
14-
#line 3 "mixed-bugfix-for-literal-as-nttp.cpp2"
1516
auto main() -> int;
16-
1717

1818
//=== Cpp2 function definitions =================================================
1919

20+
#line 1 "mixed-bugfix-for-literal-as-nttp.cpp2"
2021

2122
#line 3 "mixed-bugfix-for-literal-as-nttp.cpp2"
2223
auto main() -> int{

regression-tests/test-results/mixed-captures-in-expressions-and-postconditions.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,27 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-captures-in-expressions-and-postconditions.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-captures-in-expressions-and-postconditions.cpp2"
1214

1315
#include <algorithm>
1416
#include <vector>
1517

1618
#line 5 "mixed-captures-in-expressions-and-postconditions.cpp2"
1719
[[nodiscard]] auto main() -> int;
18-
1920

2021
#line 17 "mixed-captures-in-expressions-and-postconditions.cpp2"
2122
extern std::vector<int> vec;
2223

2324
auto insert_at(cpp2::in<int> where, cpp2::in<int> val) -> void;
24-
2525

2626
//=== Cpp2 function definitions =================================================
2727

28+
#line 1 "mixed-captures-in-expressions-and-postconditions.cpp2"
2829

2930
#line 5 "mixed-captures-in-expressions-and-postconditions.cpp2"
3031
[[nodiscard]] auto main() -> int{

regression-tests/test-results/mixed-fixed-type-aliases.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-fixed-type-aliases.cpp2"
89

910
#line 15 "mixed-fixed-type-aliases.cpp2"
1011
template<typename T> class mytype;
1112

1213

1314
//=== Cpp2 type definitions and function declarations ===========================
1415

16+
#line 1 "mixed-fixed-type-aliases.cpp2"
1517
#include <filesystem>
1618
#include <iostream>
1719
#include <typeinfo>
@@ -22,18 +24,17 @@ namespace my {
2224

2325
#line 9 "mixed-fixed-type-aliases.cpp2"
2426
auto test(auto const& x) -> void;
25-
2627

2728
#line 15 "mixed-fixed-type-aliases.cpp2"
2829
template<typename T> class mytype {
2930
public: template<typename U> static const bool myvalue;
3031
};
3132

3233
[[nodiscard]] auto main(int const argc_, char** argv_) -> int;
33-
3434

3535
//=== Cpp2 function definitions =================================================
3636

37+
#line 1 "mixed-fixed-type-aliases.cpp2"
3738

3839
#line 9 "mixed-fixed-type-aliases.cpp2"
3940
auto test(auto const& x) -> void{

regression-tests/test-results/mixed-float-literals.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-float-literals.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-float-literals.cpp2"
1214
void literals_cpp1() {
1315
// integers
1416
std::cout << 123 << std::endl;
@@ -67,14 +69,13 @@ void literals_cpp1() {
6769

6870
#line 57 "mixed-float-literals.cpp2"
6971
auto literals_cpp2() -> void;
70-
7172

7273
#line 114 "mixed-float-literals.cpp2"
7374
[[nodiscard]] auto main() -> int;
74-
7575

7676
//=== Cpp2 function definitions =================================================
7777

78+
#line 1 "mixed-float-literals.cpp2"
7879

7980
#line 57 "mixed-float-literals.cpp2"
8081
auto literals_cpp2() -> void{

regression-tests/test-results/mixed-forwarding.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-forwarding.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-forwarding.cpp2"
1214
#include <iostream>
1315
#include <utility>
1416

@@ -26,24 +28,18 @@ auto use([[maybe_unused]] auto const& unnamed_param_1) -> void;
2628

2729
// invoking each of these with an rvalue std::pair argument ...
2830
auto apply_implicit_forward(auto&& t) -> void
29-
CPP2_REQUIRES (std::is_same_v<CPP2_TYPEOF(t), std::pair<X,X>>)
30-
#line 16 "mixed-forwarding.cpp2"
31-
;
32-
31+
CPP2_REQUIRES (std::is_same_v<CPP2_TYPEOF(t), std::pair<X,X>>) ;
3332

3433
#line 20 "mixed-forwarding.cpp2"
3534
auto apply_explicit_forward(auto&& t) -> void
36-
CPP2_REQUIRES (std::is_same_v<CPP2_TYPEOF(t), std::pair<X,X>>)
37-
#line 20 "mixed-forwarding.cpp2"
38-
;
39-
35+
CPP2_REQUIRES (std::is_same_v<CPP2_TYPEOF(t), std::pair<X,X>>) ;
4036

4137
#line 25 "mixed-forwarding.cpp2"
4238
[[nodiscard]] auto main() -> int;
43-
4439

4540
//=== Cpp2 function definitions =================================================
4641

42+
#line 1 "mixed-forwarding.cpp2"
4743

4844
#line 11 "mixed-forwarding.cpp2"
4945
auto copy_from([[maybe_unused]] auto unnamed_param_1) -> void{}
@@ -52,16 +48,14 @@ auto use([[maybe_unused]] auto const& unnamed_param_1) -> void{}
5248

5349
#line 16 "mixed-forwarding.cpp2"
5450
auto apply_implicit_forward(auto&& t) -> void
55-
requires (std::is_same_v<CPP2_TYPEOF(t), std::pair<X,X>>)
56-
#line 16 "mixed-forwarding.cpp2"
57-
{
51+
requires (std::is_same_v<CPP2_TYPEOF(t), std::pair<X,X>>) {
52+
#line 17 "mixed-forwarding.cpp2"
5853
copy_from(t.first); // copies
5954
copy_from(CPP2_FORWARD(t).second);// moves
6055
}
6156
auto apply_explicit_forward(auto&& t) -> void
62-
requires (std::is_same_v<CPP2_TYPEOF(t), std::pair<X,X>>)
63-
#line 20 "mixed-forwarding.cpp2"
64-
{
57+
requires (std::is_same_v<CPP2_TYPEOF(t), std::pair<X,X>>) {
58+
#line 21 "mixed-forwarding.cpp2"
6559
copy_from(CPP2_FORWARD(t).first);// moves
6660
copy_from(CPP2_FORWARD(t).second);// moves
6761
}

regression-tests/test-results/mixed-function-expression-and-std-for-each.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-function-expression-and-std-for-each.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-function-expression-and-std-for-each.cpp2"
1214
#include <vector>
1315
#include <string>
1416
#include <span>
@@ -17,10 +19,10 @@
1719

1820
#line 7 "mixed-function-expression-and-std-for-each.cpp2"
1921
[[nodiscard]] auto main() -> int;
20-
2122

2223
//=== Cpp2 function definitions =================================================
2324

25+
#line 1 "mixed-function-expression-and-std-for-each.cpp2"
2426

2527
#line 7 "mixed-function-expression-and-std-for-each.cpp2"
2628
[[nodiscard]] auto main() -> int{

regression-tests/test-results/mixed-function-expression-and-std-ranges-for-each-with-capture.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
#include "cpp2util.h"
77

8+
#line 1 "mixed-function-expression-and-std-ranges-for-each-with-capture.cpp2"
89

910

1011
//=== Cpp2 type definitions and function declarations ===========================
1112

13+
#line 1 "mixed-function-expression-and-std-ranges-for-each-with-capture.cpp2"
1214
#include <vector>
1315
#include <ranges>
1416
#include <string>
@@ -18,10 +20,10 @@
1820

1921
#line 8 "mixed-function-expression-and-std-ranges-for-each-with-capture.cpp2"
2022
[[nodiscard]] auto main() -> int;
21-
2223

2324
//=== Cpp2 function definitions =================================================
2425

26+
#line 1 "mixed-function-expression-and-std-ranges-for-each-with-capture.cpp2"
2527

2628
#line 8 "mixed-function-expression-and-std-ranges-for-each-with-capture.cpp2"
2729
[[nodiscard]] auto main() -> int{

0 commit comments

Comments
 (0)