-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(parse): allow (to omit) semicolon after _unnamed-declaration_
- Loading branch information
Showing
6 changed files
with
101 additions
and
11 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
regression-tests/pure2-bugfix-for-unbraced-function-expression.cpp2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
t: type = { | ||
operator[]: (this, f) = { } | ||
} | ||
|
||
main: () -> int = { | ||
(x := t()) { x[:() -> _ = 0]; } | ||
(x := t()) { x[:() -> _ = 0;]; } | ||
|
||
[[assert: !(:() = 0; is int) ]] | ||
|
||
_ = :i32 = 0; | ||
[[assert: true]] | ||
|
||
return :i32 = 0; | ||
} | ||
|
||
x :== :i32 = 0; | ||
y: i32 = 0; |
Empty file.
Empty file.
60 changes: 60 additions & 0 deletions
60
regression-tests/test-results/pure2-bugfix-for-unbraced-function-expression.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
#define CPP2_IMPORT_STD Yes | ||
|
||
//=== Cpp2 type declarations ==================================================== | ||
|
||
|
||
#include "cpp2util.h" | ||
|
||
class t; | ||
|
||
|
||
//=== Cpp2 type definitions and function declarations =========================== | ||
|
||
class t { | ||
public: auto operator[](auto const& f) const& -> void; | ||
|
||
public: t() = default; | ||
public: t(t const&) = delete; /* No 'that' constructor, suppress copy */ | ||
public: auto operator=(t const&) -> void = delete; | ||
#line 3 "pure2-bugfix-for-unbraced-function-expression.cpp2" | ||
}; | ||
|
||
[[nodiscard]] auto main() -> int; | ||
|
||
|
||
#line 17 "pure2-bugfix-for-unbraced-function-expression.cpp2" | ||
auto inline constexpr x = cpp2::i32{0}; | ||
extern cpp2::i32 y; | ||
|
||
//=== Cpp2 function definitions ================================================= | ||
|
||
|
||
#line 2 "pure2-bugfix-for-unbraced-function-expression.cpp2" | ||
auto t::operator[](auto const& f) const& -> void{} | ||
|
||
#line 5 "pure2-bugfix-for-unbraced-function-expression.cpp2" | ||
[[nodiscard]] auto main() -> int{ | ||
{ | ||
auto const& x = t(); | ||
#line 6 "pure2-bugfix-for-unbraced-function-expression.cpp2" | ||
{cpp2::assert_in_bounds(x, []() -> auto { return 0; }); } | ||
} | ||
{ | ||
auto const& x = t(); | ||
#line 7 "pure2-bugfix-for-unbraced-function-expression.cpp2" | ||
{cpp2::assert_in_bounds(x, []() -> auto { return 0; }); } | ||
} | ||
|
||
#line 9 "pure2-bugfix-for-unbraced-function-expression.cpp2" | ||
cpp2::Default.expects(!((cpp2::is<int>([]() -> void { 0; }))), ""); | ||
|
||
static_cast<void>(cpp2::i32{0}); | ||
cpp2::Default.expects(true, ""); | ||
|
||
return cpp2::i32{0}; | ||
} | ||
|
||
#line 18 "pure2-bugfix-for-unbraced-function-expression.cpp2" | ||
cpp2::i32 y {0}; | ||
|
2 changes: 2 additions & 0 deletions
2
regression-tests/test-results/pure2-bugfix-for-unbraced-function-expression.cpp2.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pure2-bugfix-for-unbraced-function-expression.cpp2... ok (all Cpp2, passes safety checks) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters