Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion flang/lib/Parser/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,9 @@ 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) {
Expand Down
11 changes: 11 additions & 0 deletions flang/test/Preprocessing/pp048.F
Original file line number Diff line number Diff line change
@@ -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