Skip to content

Commit 9907337

Browse files
committed
Add printing for (multiple, flag, values)
And add support for reflecting aliases (though I ended up not using it in the final version this commit)
1 parent c2e0778 commit 9907337

File tree

45 files changed

+380
-198
lines changed

Some content is hidden

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

45 files changed

+380
-198
lines changed

include/cpp2util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,8 @@ class strict_value {
15991599
auto operator& ( strict_value const& that ) const -> strict_value requires BitwiseOps { return strict_value(t & that.t); }
16001600
auto operator^ ( strict_value const& that ) const -> strict_value requires BitwiseOps { return strict_value(t ^ that.t); }
16011601

1602+
auto has ( strict_value const& that ) const -> bool requires BitwiseOps { return t & that.t; }
1603+
16021604
auto set ( strict_value const& that ) -> void requires BitwiseOps { t |= that.t; }
16031605
auto clear ( strict_value const& that ) -> void requires BitwiseOps { t &= ~that.t; }
16041606
};

regression-tests/pure2-enum.cpp2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ main: () = {
7777
f |= file_attributes::obsolete;
7878
f2 |= file_attributes::current;
7979

80+
std::cout << "f is " << f << "\n";
81+
std::cout << "f2 is " << f2 << "\n";
8082
std::cout << "f as int is (f as int )$\n";
8183
std::cout << "f2 as int is (f2 as int )$\n";
8284
std::cout << "f == f2 is (f == f2 )$\n";

regression-tests/test-results/clang-12/pure2-enum.cpp.execution

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ f2 as int is 1
88
f is (f2) is 1
99
f2 is (f ) is 1
1010

11+
f is (cached, current, obsolete)
12+
f2 is (cached, current)
1113
f as int is 7
1214
f2 as int is 3
1315
f == f2 is 0
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:36: error: expected ‘;’ at end of member declaration
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+
| ;
25
In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:7:
3-
../../../include/cpp2util.h:1802: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.
4-
1802 | #define CPP2_REQUIRES_(...) static_assert(false, "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.")
6+
../../../include/cpp2util.h:1804: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+
1804 | #define CPP2_REQUIRES_(...) static_assert(false, "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.")
58
| ^~~~~
6-
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.cpp:17:1: note: in expansion of macro ‘CPP2_REQUIRES_’
10+
17 | CPP2_REQUIRES_ (std::is_same_v<CPP2_TYPEOF(n), std::string>)
11+
| ^~~~~~~~~~~~~~
712
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:46: error: expected ‘;’ at end of member declaration
813
In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:7:
9-
../../../include/cpp2util.h:1802: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.
10-
1802 | #define CPP2_REQUIRES_(...) static_assert(false, "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.")
14+
../../../include/cpp2util.h:1804: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.
15+
1804 | #define CPP2_REQUIRES_(...) static_assert(false, "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.")
1116
| ^~~~~
1217
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:4:1: note: in expansion of macro ‘CPP2_REQUIRES_’
1318
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: no declaration matches ‘element::element(auto:80&&) requires is_same_v<typename std::remove_cv<typename std::remove_reference<decltype(element::__ct ::n)>::type>::type, std::__cxx11::string>’
1419
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:5:11: note: candidates are: ‘element::element(const element&)’
15-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:20: note: ‘template<class auto:78> element::element(auto:78&&)’
16-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here
20+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:16:20: note: ‘template<class auto:78> element::element(auto:78&&)’
21+
16 | public: explicit element(auto&& n)
22+
| ^~~~~~~
23+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:14:7: note: ‘class element’ defined here
24+
14 | class element {
25+
| ^~~~~~~
1726
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: expected unqualified-id before ‘{’ token
1827
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:8: error: no declaration matches ‘element& element::operator=(auto:81&&) requires is_same_v<typename std::remove_cv<typename std::remove_reference<decltype(element::operator=::n)>::type>::type, std::__cxx11::string>’
1928
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:6:16: note: candidates are: ‘void element::operator=(const element&)’
2029
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:16: note: ‘template<class auto:79> element& element::operator=(auto:79&&)’
21-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here
30+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:14:7: note: ‘class element’ defined here
31+
14 | class element {
32+
| ^~~~~~~

regression-tests/test-results/gcc-10/pure2-enum.cpp.execution

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ f2 as int is 1
88
f is (f2) is 1
99
f2 is (f ) is 1
1010

11+
f is (cached, current, obsolete)
12+
f2 is (cached, current)
1113
f as int is 7
1214
f2 as int is 3
1315
f == f2 is 0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
In file included from pure2-requires-clauses.cpp:7:
2-
../../../include/cpp2util.h:1802:33: error: expected unqualified-id before ‘static_assert’
3-
1802 | #define CPP2_REQUIRES_(...) static_assert(false, "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.")
2+
../../../include/cpp2util.h:1804:33: error: expected unqualified-id before ‘static_assert’
3+
1804 | #define CPP2_REQUIRES_(...) static_assert(false, "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.")
44
| ^~~~~~~~~~~~~
55
pure2-requires-clauses.cpp2:19:1: note: in expansion of macro ‘CPP2_REQUIRES_’

regression-tests/test-results/gcc-13/pure2-enum.cpp.execution

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ f2 as int is 1
88
f is (f2) is 1
99
f2 is (f ) is 1
1010

11+
f is (cached, current, obsolete)
12+
f2 is (cached, current)
1113
f as int is 7
1214
f2 as int is 3
1315
f == f2 is 0

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010
//=== Cpp2 type definitions and function declarations ===========================
1111

12-
#line 1 "mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp2"
1312
extern cpp2::i32 x;
1413
int main() { }
1514
// ugh
1615

1716
//=== Cpp2 function definitions =================================================
1817

19-
#line 1 "mixed-bugfix-for-cpp2-comment-cpp1-sequence.cpp2"
2018
cpp2::i32 x {0};
2119

regression-tests/test-results/msvc-2022/pure2-enum.cpp.execution

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ f2 as int is 1
88
f is (f2) is 1
99
f2 is (f ) is 1
1010

11+
f is (cached, current, obsolete)
12+
f2 is (cached, current)
1113
f as int is 7
1214
f2 as int is 3
1315
f == f2 is 0

regression-tests/test-results/pure2-bounds-safety-span.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
auto print_and_decorate(auto const& thing) -> void;
1919

2020

21-
#line 1 "pure2-bounds-safety-span.cpp2"
2221

2322
//=== Cpp2 function definitions =================================================
2423

0 commit comments

Comments
 (0)