-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #331 from AljenU/fix_else_and_elif
Fix preprocessor else and elif
- Loading branch information
Showing
8 changed files
with
202 additions
and
7 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
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 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 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 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 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 |