Skip to content

Commit e3f856c

Browse files
[flang] Fix #else with trailing text
Fixed the issue, where the extra text on #else line (' Z' in the example below) caused the data from the "else" clause to be processed together with the data of "then" clause. ``` PARAMETER(A=2) PARAMETER(A=3) end ```
1 parent 6ae7177 commit e3f856c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

flang/lib/Parser/preprocessor.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,9 @@ void Preprocessor::Directive(const TokenSequence &dir, Prescanner &prescanner) {
684684
dir.GetIntervalProvenanceRange(j, tokens - j),
685685
"#else: excess tokens at end of directive"_port_en_US);
686686
}
687-
} else if (ifStack_.empty()) {
687+
}
688+
689+
if (ifStack_.empty()) {
688690
prescanner.Say(dir.GetTokenProvenanceRange(dirOffset),
689691
"#else: not nested within #if, #ifdef, or #ifndef"_err_en_US);
690692
} else if (ifStack_.top() != CanDeadElseAppear::Yes) {

0 commit comments

Comments
 (0)