forked from hsutter/cppfront
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also, reject `=` assignment expressions in `if` conditions. They're already disallowed in loop conditions, and it's an oversight that they were not already disallowed in `if` conditions... the `if` condition is supposed to take *logical-or-expression* (the conditional expression production) like the loop conditions do.
- Loading branch information
Showing
10 changed files
with
123 additions
and
19 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
regression-tests/pure2-initialization-safety-with-else-if.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,25 @@ | ||
main: (args) = { | ||
p : *int; | ||
|
||
a := 1; | ||
b := 2; | ||
c := 3; | ||
d := 4; | ||
|
||
if args.size() == 3 { | ||
p = a&; | ||
} else if true { | ||
if args.size() == 2 { | ||
p = c&; | ||
} else if b > 0 { | ||
p = a&; | ||
} | ||
else { | ||
p = d&; | ||
} | ||
} else { | ||
p = c&; | ||
} | ||
|
||
std::cout << p* << std::endl; | ||
} |
1 change: 1 addition & 0 deletions
1
...ession-tests/test-results/clang-12/pure2-initialization-safety-with-else-if.cpp.execution
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 @@ | ||
1 |
Empty file.
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/gcc-10/pure2-initialization-safety-with-else-if.cpp.execution
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 @@ | ||
1 |
Empty file.
1 change: 1 addition & 0 deletions
1
...ssion-tests/test-results/msvc-2022/pure2-initialization-safety-with-else-if.cpp.execution
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 @@ | ||
1 |
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/msvc-2022/pure2-initialization-safety-with-else-if.cpp.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 @@ | ||
pure2-initialization-safety-with-else-if.cpp |
47 changes: 47 additions & 0 deletions
47
regression-tests/test-results/pure2-initialization-safety-with-else-if.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,47 @@ | ||
|
||
#define CPP2_USE_MODULES Yes | ||
|
||
//=== Cpp2 type declarations ==================================================== | ||
|
||
|
||
#include "cpp2util.h" | ||
|
||
|
||
|
||
//=== Cpp2 type definitions and function declarations =========================== | ||
|
||
#line 1 "pure2-initialization-safety-with-else-if.cpp2" | ||
auto main(int const argc_, char const* const* const argv_) -> int; | ||
|
||
|
||
//=== Cpp2 function definitions ================================================= | ||
|
||
#line 1 "pure2-initialization-safety-with-else-if.cpp2" | ||
auto main(int const argc_, char const* const* const argv_) -> int{ | ||
auto args = cpp2::make_args(argc_, argv_); | ||
#line 2 "pure2-initialization-safety-with-else-if.cpp2" | ||
cpp2::deferred_init<int*> p; | ||
|
||
auto a {1}; | ||
auto b {2}; | ||
auto c {3}; | ||
auto d {4}; | ||
|
||
if (CPP2_UFCS_0(size, args)==3) { | ||
p.construct(&a); | ||
}else {if (true) { | ||
if (CPP2_UFCS_0(size, args)==2) { | ||
p.construct(&c); | ||
}else {if (cpp2::cmp_greater(std::move(b),0)) { | ||
p.construct(&a); | ||
} | ||
else { | ||
p.construct(&d); | ||
}} | ||
}else { | ||
p.construct(&c); | ||
}} | ||
|
||
std::cout << *cpp2::assert_not_null(std::move(p.value())) << std::endl; | ||
} | ||
|
2 changes: 2 additions & 0 deletions
2
regression-tests/test-results/pure2-initialization-safety-with-else-if.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-initialization-safety-with-else-if.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