Skip to content

Commit ed566cd

Browse files
committed
test: update test for preprocessor #elif parsing
Only the first true branch of a #if-#elif-#else should be included
1 parent 412cade commit ed566cd

File tree

1 file changed

+116
-1
lines changed

1 file changed

+116
-1
lines changed

test/test_source/pp/preproc_elif.F90

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
subroutine preprocessor_elif(var)
1+
subroutine preprocessor_elif(var, var3, var4, var5, var6)
22

33
#if 0
44
#define MYTYPE character
@@ -21,4 +21,119 @@ subroutine preprocessor_elif(var)
2121

2222
PRINT*, var
2323

24+
#if 1
25+
#define PART1 1,
26+
#elif 0
27+
#define PART2 2,
28+
#elif 1
29+
#define PART3 3,
30+
#else
31+
#define PART4 4
32+
#endif
33+
34+
#ifndef PART1
35+
#define PART1 5,
36+
#endif
37+
#ifndef PART2
38+
#define PART2 5,
39+
#endif
40+
#ifndef PART3
41+
#define PART3 5,
42+
#endif
43+
#ifndef PART4
44+
#define PART4 5
45+
#endif
46+
47+
REAL(PART1 PART2 PART3 PART4) :: var3
48+
49+
#undef PART1
50+
#undef PART2
51+
#undef PART3
52+
#undef PART4
53+
54+
#if 0
55+
#define PART1 1,
56+
#elif 1
57+
#define PART2 2,
58+
#elif 1
59+
#define PART3 3,
60+
#else
61+
#define PART4 4
62+
#endif
63+
64+
#ifndef PART1
65+
#define PART1 5,
66+
#endif
67+
#ifndef PART2
68+
#define PART2 5,
69+
#endif
70+
#ifndef PART3
71+
#define PART3 5,
72+
#endif
73+
#ifndef PART4
74+
#define PART4 5
75+
#endif
76+
77+
REAL(PART1 PART2 PART3 PART4) :: var4
78+
79+
#undef PART1
80+
#undef PART2
81+
#undef PART3
82+
#undef PART4
83+
84+
#if 0
85+
#define PART1 1,
86+
#elif 0
87+
#define PART2 2,
88+
#elif 0
89+
#define PART3 3,
90+
#else
91+
#define PART4 4
92+
#endif
93+
94+
#ifndef PART1
95+
#define PART1 5,
96+
#endif
97+
#ifndef PART2
98+
#define PART2 5,
99+
#endif
100+
#ifndef PART3
101+
#define PART3 5,
102+
#endif
103+
#ifndef PART4
104+
#define PART4 5
105+
#endif
106+
107+
REAL(PART1 PART2 PART3 PART4) :: var5
108+
109+
#undef PART1
110+
#undef PART2
111+
#undef PART3
112+
#undef PART4
113+
114+
#if 1
115+
#define PART1 1,
116+
#elif 1
117+
#define PART2 2,
118+
#elif 0
119+
#define PART3 3,
120+
#else
121+
#define PART4 4
122+
#endif
123+
124+
#ifndef PART1
125+
#define PART1 5,
126+
#endif
127+
#ifndef PART2
128+
#define PART2 5,
129+
#endif
130+
#ifndef PART3
131+
#define PART3 5,
132+
#endif
133+
#ifndef PART4
134+
#define PART4 5
135+
#endif
136+
137+
REAL(PART1 PART2 PART3 PART4) :: var6
138+
24139
endsubroutine preprocessor_elif

0 commit comments

Comments
 (0)