[flang] Fix #else with trailing text (#138045)
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. ``` #ifndef XYZ42 PARAMETER(A=2) #else Z PARAMETER(A=3) #endif end ```
This commit is contained in:
parent
f46ff4c204
commit
36541ec3ca
@ -684,7 +684,8 @@ void Preprocessor::Directive(const TokenSequence &dir, Prescanner &prescanner) {
|
||||
dir.GetIntervalProvenanceRange(j, tokens - j),
|
||||
"#else: excess tokens at end of directive"_port_en_US);
|
||||
}
|
||||
} else if (ifStack_.empty()) {
|
||||
}
|
||||
if (ifStack_.empty()) {
|
||||
prescanner.Say(dir.GetTokenProvenanceRange(dirOffset),
|
||||
"#else: not nested within #if, #ifdef, or #ifndef"_err_en_US);
|
||||
} else if (ifStack_.top() != CanDeadElseAppear::Yes) {
|
||||
|
11
flang/test/Preprocessing/pp048.F
Normal file
11
flang/test/Preprocessing/pp048.F
Normal file
@ -0,0 +1,11 @@
|
||||
! RUN: %flang -E %s 2>&1 | FileCheck %s
|
||||
#ifndef XYZ42
|
||||
PARAMETER(A=2)
|
||||
#else Z
|
||||
PARAMETER(A=3)
|
||||
#endif
|
||||
! Ensure that "PARAMETER(A" is printed only once
|
||||
! CHECK: PARAMETER(A
|
||||
! CHECK-NOT: PARAMETER(A
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user