[all-commits] [llvm/llvm-project] f86eb5: [flang-rt][NAMELIST] Accept empty scalar assignmen...
Kareem Ergawy via All-commits
all-commits at lists.llvm.org
Thu Jul 30 05:57:28 PDT 2026
Branch: refs/heads/users/ergawy/namelist_empty_scalar_value
Home: https://github.com/llvm/llvm-project
Commit: f86eb5d02df63a7c3593076f5f1bdb3ae1740bfa
https://github.com/llvm/llvm-project/commit/f86eb5d02df63a7c3593076f5f1bdb3ae1740bfa
Author: ergawy <kareem.ergawy at gmail.com>
Date: 2026-07-30 (Thu, 30 Jul 2026)
Changed paths:
M flang-rt/include/flang-rt/runtime/namelist.h
M flang-rt/lib/runtime/namelist.cpp
A flang-rt/test/Driver/namelist-empty-scalar-logical.f90
M flang-rt/unittests/Runtime/Namelist.cpp
M flang/docs/Extensions.md
Log Message:
-----------
[flang-rt][NAMELIST] Accept empty scalar assignments as a language extension
Extend Flang's NAMELIST input to accept an assignment to a scalar item
whose value is omitted, e.g. `l=` in
&nml l= i_count=7 r_value=2.72/
leaving the item's current value unchanged. This form is non-standard
(F2023 13.11.3.2 requires a value to follow the `=` for a scalar item)
but is accepted by classic nvfortran and gfortran; users porting code
between compilers have come to rely on it. `flang/docs/Extensions.md`
is updated to list the new NAMELIST extension alongside the existing
`$`/`&` group-start and mid-value `!`-comment extensions.
Implementation
--------------
Every `EditIntegerInput` / `EditRealInput` / `EditLogicalInput` /
`EditCharacterInput` list-directed arm starts with
if (IsNamelistNameOrSlash(io)) return false; // no value
which peeks ahead (via `SavedPosition`, no stream consumption) for a
`<name>=` / `<name>%` / `<name>(` shape or one of the terminators
`/` `&` `$`, letting the reader bail cleanly for empty values and
short-array ends. The helper's first line is
if (!listInput || !listInput->namelistGroup()) return false;
`InputNamelist` however called `ResetForNextNamelistItem` with
`useDescriptor->rank() > 0 ? &group : nullptr`, so `namelistGroup_`
stayed null for scalars. The peek was silently disabled and the
value reader consumed the next name-value pair's name as a bare token,
producing a "Bad character" runtime abort.
Pass `&group` unconditionally to `ResetForNextNamelistItem`. Today
`IsNamelistNameOrSlash` uses `namelistGroup_` only as a boolean gate
(never as a lookup table), so widening it is a no-op for arrays and
enables the same empty-value / next-name detection for scalars.
`NamelistTests.NanInputAmbiguity` (which motivated the original
pointer form) still passes; three new tests cover the empty-scalar
case, the empty-array case, and an empty scalar surrounded by arrays.
Commit: 330a9c3c0ee9edcc101f5dc9265dfac9e40e4012
https://github.com/llvm/llvm-project/commit/330a9c3c0ee9edcc101f5dc9265dfac9e40e4012
Author: ergawy <kareem.ergawy at gmail.com>
Date: 2026-07-30 (Thu, 30 Jul 2026)
Changed paths:
M flang-rt/lib/runtime/namelist.cpp
Log Message:
-----------
[flang-rt] Reword ResetForNextNamelistItem comment as an extension
Commit: af7fef717c5fe7931238058ca88dea62fa728342
https://github.com/llvm/llvm-project/commit/af7fef717c5fe7931238058ca88dea62fa728342
Author: ergawy <kareem.ergawy at gmail.com>
Date: 2026-07-30 (Thu, 30 Jul 2026)
Changed paths:
M flang-rt/unittests/Runtime/Namelist.cpp
Log Message:
-----------
[flang-rt] Reword NamelistTests comments as an extension
Commit: 89237db30bd5ec94a78821c8ee735df9f55ab38f
https://github.com/llvm/llvm-project/commit/89237db30bd5ec94a78821c8ee735df9f55ab38f
Author: ergawy <kareem.ergawy at gmail.com>
Date: 2026-07-30 (Thu, 30 Jul 2026)
Changed paths:
M flang-rt/test/Driver/namelist-empty-scalar-logical.f90
Log Message:
-----------
[flang-rt] Reword namelist-empty-scalar-logical driver test header as an extension
Compare: https://github.com/llvm/llvm-project/compare/2be863b8ad21...89237db30bd5
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list