[flang] Allow explicit '+' in NAMELIST input subscripts

Array subscripts and substring limits in NAMELIST input are
allowed to bear an explicit plus sign.

Differential Revision: https://reviews.llvm.org/D117818
This commit is contained in:
Peter Klausler 2022-01-12 15:10:20 -08:00
parent cfae2c65db
commit 922c29ccf1
2 changed files with 3 additions and 3 deletions

View file

@ -99,7 +99,7 @@ static std::optional<SubscriptValue> GetSubscriptValue(IoStatementState &io) {
std::optional<SubscriptValue> value;
std::optional<char32_t> ch{io.GetCurrentChar()};
bool negate{ch && *ch == '-'};
if (negate) {
if ((ch && *ch == '+') || negate) {
io.HandleRelativePosition(1);
ch = io.GetCurrentChar();
}

View file

@ -135,7 +135,7 @@ TEST(NamelistTests, Subscripts) {
aDesc->GetDimension(1).SetBounds(-1, 1);
const NamelistGroup::Item items[]{{"a", *aDesc}};
const NamelistGroup group{"justa", 1, items};
static char t1[]{"&justa A(0,1:-1:-2)=1 2/"};
static char t1[]{"&justa A(0,+1:-1:-2)=1 2/"};
StaticDescriptor<1, true> statDesc;
Descriptor &internalDesc{statDesc.descriptor()};
internalDesc.Establish(TypeCode{CFI_type_char},
@ -223,7 +223,7 @@ TEST(NamelistTypes, ArraySubstring) {
std::vector<std::string>{"abcdefgh", "ijklmnop"}, 8)};
const NamelistGroup::Item items[]{{"a", *scDesc}};
const NamelistGroup group{"justa", 1, items};
static char t1[]{"&justa A(:)(2:5)='BCDE' 'JKLM'/"};
static char t1[]{"&justa A(:)(2:+5)='BCDE' 'JKLM'/"};
StaticDescriptor<1, true> statDesc;
Descriptor &internalDesc{statDesc.descriptor()};
internalDesc.Establish(TypeCode{CFI_type_char},