[flang] fixes

Original-commit: flang-compiler/f18@f504e6a938
Reviewed-on: https://github.com/flang-compiler/f18/pull/496
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-06-17 12:29:20 -07:00
parent 7c4b790c5e
commit fd54622481
2 changed files with 9 additions and 4 deletions

View File

@ -224,9 +224,12 @@ static DecodedCharacter DecodeEscapedCharacter(
return {static_cast<char32_t>(16 * HexadecimalDigitValue(cp[2]) +
HexadecimalDigitValue(cp[3])),
4};
} else {
// unknown escape - ignore the '\' (PGI compatibility)
} else if (IsLetter(cp[1])) {
// Unknown escape - ignore the '\' (PGI compatibility)
return {static_cast<unsigned char>(cp[1]), 2};
} else {
// Not an escape character.
return {'\\', 1};
}
}
return {static_cast<unsigned char>(cp[0]), 1};

View File

@ -330,7 +330,9 @@ void Prescanner::SkipCComments() {
nextLine_ = at_ = after;
NextLine();
} else {
Say(GetProvenance(at_), "unclosed C-style comment"_err_en_US);
// Don't emit any messages about unclosed C-style comments, because
// the sequence /* can appear legally in a FORMAT statement. There's
// no ambiguity, since the sequence */ cannot appear legally.
break;
}
} else if (inPreprocessorDirective_ && at_[0] == '\\' && at_ + 2 < limit_ &&
@ -569,7 +571,7 @@ void Prescanner::QuotedCharacterLiteral(
encoding, at_, static_cast<std::size_t>(limit_ - at_), escapesEnabled)};
if (decoded.bytes <= 0) {
Say(GetProvenanceRange(start, at_),
"Bad character in character literal"_err_en_US);
"Bad character in character literal"_en_US);
// Just eat a byte and press on.
decoded.codepoint = static_cast<unsigned char>(*at_);
decoded.bytes = 1;