-
-
Notifications
You must be signed in to change notification settings - Fork 51
Fix preprocessor else and elif #331
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7f892ac
test: Add test for preprocessor #if-#else parsing
AljenU 21bd331
fix: preprocessor #else branch
AljenU faf6d7e
test: Add test for preprocessor #elif parsing
AljenU 10dc58f
fix: preprocessor #elif no longer skips whole file
AljenU a5d6e8f
test: Update test for preprocessor #elif parsing
AljenU 412cade
fix: preprocessor indexing error in #elif parsing
AljenU ed566cd
test: update test for preprocessor #elif parsing
AljenU a1645e6
fix: preprocessor #elif only includes first true branch
AljenU 4f7bc5c
refactor: preprocessor elif test
gnikit dc3449e
chore: updated CHANGELOG
gnikit 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| subroutine preprocessor_elif(var, var3, var4, var5, var6) | ||
|
|
||
| ! This file, as used in test_preproc, checks that | ||
| ! 1. the steps after the preprocessor parsing has fully finished, are only | ||
| ! using content from the parts within the preprocessor if-elif-else that | ||
| ! should be used. To do this, it has some regular fortran code within the | ||
| ! #if and #elif. | ||
| ! 2. the #endif correctly concludes the if-elif, so any new #define statements | ||
| ! that come after the #endif, are picked up during the preprocessor parsing. | ||
|
|
||
| #if 0 | ||
| integer, intent(in) :: var | ||
| #elif 1 | ||
| integer, intent(inout) :: var | ||
| var = 3 | ||
| #else | ||
| integer, intent(out) :: var | ||
| var = 5 | ||
| #endif | ||
|
|
||
| #define OTHERTYPE integer | ||
|
|
||
| OTHERTYPE :: var2 | ||
|
|
||
| PRINT*, var | ||
|
|
||
| endsubroutine preprocessor_elif |
This file contains hidden or 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,33 @@ | ||
| subroutine preprocessor_elif_elif_skip() | ||
|
|
||
| ! This file, as used in test_preproc, and together with the two similar files, | ||
| ! tests that when there is an if-elif-elif-else, only the first branch that | ||
| ! evaluates to true is used, and the others ignored. Also when multiple | ||
| ! conditions evaluate to true. | ||
|
|
||
| #if 0 | ||
| #define PART1 0 | ||
| #elif 1 | ||
| #define PART2 1 | ||
| #elif 1 | ||
| #define PART3 0 | ||
| #else | ||
| #define PART4 0 | ||
| #endif | ||
|
|
||
| #ifndef PART1 | ||
| #define PART1 0 | ||
| #endif | ||
| #ifndef PART2 | ||
| #define PART2 0 | ||
| #endif | ||
| #ifndef PART3 | ||
| #define PART3 0 | ||
| #endif | ||
| #ifndef PART4 | ||
| #define PART4 0 | ||
| #endif | ||
|
|
||
| integer, parameter :: res = PART1+PART2+PART3+PART4 | ||
|
|
||
| end subroutine preprocessor_elif_elif_skip |
This file contains hidden or 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,21 @@ | ||
| subroutine preprocessor_else(var) | ||
|
|
||
| #if 0 | ||
| #define MYTYPE logical | ||
| #else | ||
| #define MYTYPE integer | ||
| #endif | ||
|
|
||
| MYTYPE :: var0 | ||
|
|
||
| #undef MYTYPE | ||
|
|
||
| #if 1 | ||
| #define MYTYPE real | ||
| #else | ||
| #define MYTYPE character | ||
| #endif | ||
|
|
||
| MYTYPE :: var1 | ||
|
|
||
| endsubroutine preprocessor_else |
This file contains hidden or 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,33 @@ | ||
| subroutine preprocessor_if_elif_else() | ||
|
|
||
| ! This file, as used in test_preproc, and together with the two similar files, | ||
| ! tests that when there is an if-elif-elif-else, only the first branch that | ||
| ! evaluates to true is used, and the others ignored. Also when multiple | ||
| ! conditions evaluate to true. | ||
|
|
||
| #if 0 | ||
| #define PART1 0 | ||
| #elif 0 | ||
| #define PART2 0 | ||
| #elif 0 | ||
| #define PART3 0 | ||
| #else | ||
| #define PART4 1 | ||
| #endif | ||
|
|
||
| #ifndef PART1 | ||
| #define PART1 0 | ||
| #endif | ||
| #ifndef PART2 | ||
| #define PART2 0 | ||
| #endif | ||
| #ifndef PART3 | ||
| #define PART3 0 | ||
| #endif | ||
| #ifndef PART4 | ||
| #define PART4 0 | ||
| #endif | ||
|
|
||
| integer, parameter :: res = PART1+PART2+PART3+PART4 | ||
|
|
||
| endsubroutine preprocessor_if_elif_else |
This file contains hidden or 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,33 @@ | ||
| subroutine preprocessor_if_elif_skip() | ||
|
|
||
| ! This file, as used in test_preproc, and together with the two similar files, | ||
| ! tests that when there is an if-elif-elif-else, only the first branch that | ||
| ! evaluates to true is used, and the others ignored. Also when multiple | ||
| ! conditions evaluate to true. | ||
|
|
||
| #if 1 | ||
| #define PART1 1 | ||
| #elif 0 | ||
| #define PART2 0 | ||
| #elif 1 | ||
| #define PART3 0 | ||
| #else | ||
| #define PART4 0 | ||
| #endif | ||
|
|
||
| #ifndef PART1 | ||
| #define PART1 0 | ||
| #endif | ||
| #ifndef PART2 | ||
| #define PART2 0 | ||
| #endif | ||
| #ifndef PART3 | ||
| #define PART3 0 | ||
| #endif | ||
| #ifndef PART4 | ||
| #define PART4 0 | ||
| #endif | ||
|
|
||
| integer, parameter :: res = PART1+PART2+PART3+PART4 | ||
|
|
||
| end subroutine preprocessor_if_elif_skip |
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.
Uh oh!
There was an error while loading. Please reload this page.