-
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.
- Loading branch information
1 parent
da1cc61
commit 8066ef9
Showing
13 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
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,27 @@ | ||
main: (args) = { | ||
p : *int; | ||
|
||
a := 1; | ||
b := 2; | ||
c := 3; | ||
d := 4; | ||
|
||
if args.argc == 3 { | ||
p = a&; | ||
} else if b > 2 { | ||
if args.argc == 2 { | ||
p = c&; | ||
} else { | ||
if b > 0 { | ||
p = a&; | ||
} | ||
else { | ||
p = d&; | ||
} | ||
} | ||
} else { | ||
// p = c&; | ||
} | ||
|
||
std::cout << p* << std::endl; | ||
} |
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,39 @@ | ||
main: (args) = { | ||
p : *int; | ||
|
||
a := 1; | ||
b := 2; | ||
c := 3; | ||
d := 4; | ||
|
||
if args.argc > 20 { | ||
c = 20; | ||
} else if args.argc > 10 { | ||
c = 10; | ||
} else { | ||
if args.argc % 2 { | ||
b = 2; | ||
} else { | ||
b = 1; | ||
} | ||
} | ||
|
||
if args.argc == 3 { | ||
p = a&; | ||
} else if b > 2 { | ||
if args.argc == 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
regression-tests/test-results/apple-clang-14/pure2-nested-ifs.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 @@ | ||
3 |
Empty file.
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/clang-12/pure2-nested-ifs.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 @@ | ||
3 |
Empty file.
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/gcc-10/pure2-nested-ifs.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 @@ | ||
3 |
Empty file.
1 change: 1 addition & 0 deletions
1
regression-tests/test-results/msvc-2022/pure2-nested-ifs.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 @@ | ||
3 |
Empty file.
9 changes: 9 additions & 0 deletions
9
regression-tests/test-results/pure2-nested-ifs-error.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,9 @@ | ||
pure2-nested-ifs-error.cpp2... | ||
pure2-nested-ifs-error.cpp2(2,5): error: local variable p must be initialized on both branches or neither branch | ||
pure2-nested-ifs-error.cpp2(9,5): error: "if" initializes p on: | ||
branch starting at line 9 | ||
branch starting at line 11 | ||
but not on: | ||
branch starting at line 22 | ||
==> program violates initialization safety guarantee - see previous errors | ||
|
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,61 @@ | ||
|
||
#define CPP2_USE_MODULES Yes | ||
|
||
//=== Cpp2 type declarations ==================================================== | ||
|
||
|
||
#include "cpp2util.h" | ||
|
||
|
||
|
||
//=== Cpp2 type definitions and function declarations =========================== | ||
|
||
#line 1 "pure2-nested-ifs.cpp2" | ||
auto main(int const argc_, char const* const* const argv_) -> int; | ||
|
||
|
||
//=== Cpp2 function definitions ================================================= | ||
|
||
#line 1 "pure2-nested-ifs.cpp2" | ||
auto main(int const argc_, char const* const* const argv_) -> int{ | ||
auto args = cpp2::make_args(argc_, argv_); | ||
#line 2 "pure2-nested-ifs.cpp2" | ||
cpp2::deferred_init<int*> p; | ||
|
||
auto a {1}; | ||
auto b {2}; | ||
auto c {3}; | ||
auto d {4}; | ||
|
||
if (cpp2::cmp_greater(args.argc,20)) { | ||
c = 20; | ||
} else if (cpp2::cmp_greater(args.argc,10)) { | ||
c = 10; | ||
}else { | ||
if (args.argc % 2) { | ||
b = 2; | ||
}else { | ||
b = 1; | ||
} | ||
} | ||
|
||
if (args.argc==3) { | ||
p.construct(&a); | ||
} else if (cpp2::cmp_greater(b,2)) { | ||
if (args.argc==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; | ||
} | ||
|
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-nested-ifs.cpp2... ok (all Cpp2, passes safety checks) | ||
|