forked from OSchip/llvm-project
[flang] Set right "inNamelist" flag
NAMELIST I/O was inconsistent in its choice of which set of I/O modes to set the "inNamelist" flag. The wrong choice was in the set of modes that are part of the persistent state of an I/O connection; the right place is the set of modes that are reinitialized at the beginning of each I/O statement so that they can be modified by READ/WRITE control list specifiers and FORMAT control edit descriptors. Fix. Differential Revision: https://reviews.llvm.org/D118745
This commit is contained in:
parent
ddd3807e69
commit
9772dbba74
|
@ -220,7 +220,7 @@ public:
|
||||||
// Skips spaces, advances records, and ignores NAMELIST comments
|
// Skips spaces, advances records, and ignores NAMELIST comments
|
||||||
std::optional<char32_t> GetNextNonBlank() {
|
std::optional<char32_t> GetNextNonBlank() {
|
||||||
auto ch{GetCurrentChar()};
|
auto ch{GetCurrentChar()};
|
||||||
bool inNamelist{GetConnectionState().modes.inNamelist};
|
bool inNamelist{mutableModes().inNamelist};
|
||||||
while (!ch || *ch == ' ' || *ch == '\t' || (inNamelist && *ch == '!')) {
|
while (!ch || *ch == ' ' || *ch == '\t' || (inNamelist && *ch == '!')) {
|
||||||
if (ch && (*ch == ' ' || *ch == '\t')) {
|
if (ch && (*ch == ' ' || *ch == '\t')) {
|
||||||
HandleRelativePosition(1);
|
HandleRelativePosition(1);
|
||||||
|
|
|
@ -28,9 +28,9 @@ static inline char32_t GetComma(IoStatementState &io) {
|
||||||
bool IONAME(OutputNamelist)(Cookie cookie, const NamelistGroup &group) {
|
bool IONAME(OutputNamelist)(Cookie cookie, const NamelistGroup &group) {
|
||||||
IoStatementState &io{*cookie};
|
IoStatementState &io{*cookie};
|
||||||
io.CheckFormattedStmtType<Direction::Output>("OutputNamelist");
|
io.CheckFormattedStmtType<Direction::Output>("OutputNamelist");
|
||||||
ConnectionState &connection{io.GetConnectionState()};
|
io.mutableModes().inNamelist = true;
|
||||||
connection.modes.inNamelist = true;
|
|
||||||
char comma{static_cast<char>(GetComma(io))};
|
char comma{static_cast<char>(GetComma(io))};
|
||||||
|
ConnectionState &connection{io.GetConnectionState()};
|
||||||
// Internal functions to advance records and convert case
|
// Internal functions to advance records and convert case
|
||||||
const auto EmitWithAdvance{[&](char ch) -> bool {
|
const auto EmitWithAdvance{[&](char ch) -> bool {
|
||||||
return (!connection.NeedAdvance(1) || io.AdvanceRecord()) &&
|
return (!connection.NeedAdvance(1) || io.AdvanceRecord()) &&
|
||||||
|
@ -355,8 +355,7 @@ static void SkipNamelistGroup(IoStatementState &io) {
|
||||||
bool IONAME(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
|
bool IONAME(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
|
||||||
IoStatementState &io{*cookie};
|
IoStatementState &io{*cookie};
|
||||||
io.CheckFormattedStmtType<Direction::Input>("InputNamelist");
|
io.CheckFormattedStmtType<Direction::Input>("InputNamelist");
|
||||||
ConnectionState &connection{io.GetConnectionState()};
|
io.mutableModes().inNamelist = true;
|
||||||
connection.modes.inNamelist = true;
|
|
||||||
IoErrorHandler &handler{io.GetIoErrorHandler()};
|
IoErrorHandler &handler{io.GetIoErrorHandler()};
|
||||||
auto *listInput{io.get_if<ListDirectedStatementState<Direction::Input>>()};
|
auto *listInput{io.get_if<ListDirectedStatementState<Direction::Input>>()};
|
||||||
RUNTIME_CHECK(handler, listInput != nullptr);
|
RUNTIME_CHECK(handler, listInput != nullptr);
|
||||||
|
@ -485,8 +484,7 @@ bool IONAME(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
|
||||||
|
|
||||||
bool IsNamelistName(IoStatementState &io) {
|
bool IsNamelistName(IoStatementState &io) {
|
||||||
if (io.get_if<ListDirectedStatementState<Direction::Input>>()) {
|
if (io.get_if<ListDirectedStatementState<Direction::Input>>()) {
|
||||||
ConnectionState &connection{io.GetConnectionState()};
|
if (io.mutableModes().inNamelist) {
|
||||||
if (connection.modes.inNamelist) {
|
|
||||||
SavedPosition savedPosition{io};
|
SavedPosition savedPosition{io};
|
||||||
if (auto ch{io.GetNextNonBlank()}) {
|
if (auto ch{io.GetNextNonBlank()}) {
|
||||||
if (IsLegalIdStart(*ch)) {
|
if (IsLegalIdStart(*ch)) {
|
||||||
|
|
Loading…
Reference in New Issue