[flang] Fix #else after triggered #elif.

Original-commit: flang-compiler/f18@77db3281ec
This commit is contained in:
peter klausler 2018-02-05 14:45:32 -08:00
parent 16c6f534a5
commit eed938f5c4
1 changed files with 12 additions and 8 deletions

View File

@ -611,12 +611,16 @@ bool Preprocessor::SkipDisabledConditionalCode(
if (nesting-- == 0) {
return true;
}
} else if (isElseActive == IsElseActive::Yes && nesting == 0 &&
(dn == "else" ||
(dn == "elif" &&
IsIfPredicateTrue(*line, rest, line->size() - rest)))) {
ifStack_.push(CanDeadElseAppear::No);
return true;
} else if (isElseActive == IsElseActive::Yes && nesting == 0) {
if (dn == "else") {
ifStack_.push(CanDeadElseAppear::No);
return true;
}
if (dn == "elif" &&
IsIfPredicateTrue(*line, rest, line->size() - rest)) {
ifStack_.push(CanDeadElseAppear::Yes);
return true;
}
}
}
Complain("#"s + dirName + ": missing #endif");
@ -649,8 +653,8 @@ static std::int64_t ExpressionValue(const TokenSequence &token,
enum Operator {
PARENS,
CONST,
NOTZERO /*!*/,
COMPLEMENT /*~*/,
NOTZERO, // !
COMPLEMENT, // ~
UPLUS,
UMINUS,
POWER,