-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix conditional expressions short circuit behaviour
- Loading branch information
1 parent
a6f5a8f
commit 54298c2
Showing
9 changed files
with
59 additions
and
18 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
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
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
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
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
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
26 changes: 26 additions & 0 deletions
26
ctowasm/test/samples/subset5/valid/conditional_expression.c
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,26 @@ | ||
// Test conditional expressions | ||
#include <source_stdlib> | ||
|
||
int f() { | ||
print_int(-1); | ||
return -1; | ||
} | ||
|
||
int main() { | ||
int x = 1 ? 2 : 3; | ||
print_int(x); | ||
|
||
// test that implicit arithmetic conversion works | ||
long y = 100; | ||
print_long(x == 2 ? y : x); | ||
|
||
// test that short circuiting works | ||
int a = 1 ? 1 : f(); // f() should not be called | ||
int b = 0 ? f() : 2; // f() should not be called | ||
print_int(a); | ||
print_int(b); | ||
|
||
// test that conditionals can be used as statements and side effects will be included | ||
1 ? f() : f(); | ||
0 ? f() : f(); | ||
} |
7 changes: 0 additions & 7 deletions
7
ctowasm/test/samples/subset5/valid/conditional_expression_1.c
This file was deleted.
Oops, something went wrong.
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