-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support switch-case with fall throughs #68
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6e696d5
DEV: Added options for fall through in Select and CaseStmt nodes
czgdp1807 753a7cd
DEV: Support switch-case with fall throughs
czgdp1807 02d13b5
DEV: Add support for transforming switch-case with fall throughs to i…
czgdp1807 ec138ba
TEST: Add test for switch-case with fall throughs
czgdp1807 9b89eab
TEST: Register test switch_case_02.cpp
czgdp1807 d8139bf
DEV: Set enable_fall_through to false
czgdp1807 a582cfe
DEV: Added ASR verify for Select::m_enable_fall_through
czgdp1807 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include <iostream> | ||
|
||
int switch_case_with_fall_through(int x) { | ||
int value = x; | ||
switch(x) { | ||
case 1: { | ||
value = 2*value; | ||
break; | ||
} | ||
case 2: { | ||
value = 3*value; | ||
} | ||
case 3: { | ||
value = 4*value; | ||
break; | ||
} | ||
case 4: { | ||
value = 5*value; | ||
} | ||
default: { | ||
value = 6*value; | ||
} | ||
} | ||
return value; | ||
} | ||
|
||
|
||
int main() { | ||
int value; | ||
value = switch_case_with_fall_through(1); | ||
std::cout<<value<<std::endl; | ||
if( value != 2 ) { | ||
exit(2); | ||
} | ||
|
||
value = switch_case_with_fall_through(2); | ||
std::cout<<value<<std::endl; | ||
if( value != 24 ) { | ||
exit(2); | ||
} | ||
|
||
value = switch_case_with_fall_through(3); | ||
std::cout<<value<<std::endl; | ||
if( value != 12 ) { | ||
exit(2); | ||
} | ||
|
||
value = switch_case_with_fall_through(4); | ||
std::cout<<value<<std::endl; | ||
if( value != 120 ) { | ||
exit(2); | ||
} | ||
|
||
value = switch_case_with_fall_through(7); | ||
std::cout<<value<<std::endl; | ||
if( value != 42 ) { | ||
exit(2); | ||
} | ||
|
||
return 0; | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an even stronger requirement, which is fine. It's always good to start strong, and relax later if needed, than the other way round.