[flang] Fix parsing bug on DATA statement
authorTim Keith <tkeith@nvidia.com>
Fri, 21 Feb 2020 23:31:12 +0000 (15:31 -0800)
committerTim Keith <tkeith@nvidia.com>
Fri, 21 Feb 2020 23:31:12 +0000 (15:31 -0800)
commit28d8a67d43aff990d331852178a86e0bf0a94f30
treeddf860ca7eff02308a60ba64c46d193d2ff3cf87
parentdf1b4b144e81a1219b9daf9f2aa765bc0beed800
[flang] Fix parsing bug on DATA statement

This DATA statement was getting a parsing error:
`data x /a(i)%b/`

The parser was expecting the ending '/' where the '%' was. The problem
was parsing `a(i)` as a structure constructor. Instead, move the
constant subobject case before structure constructor, but match it only
if not followed by '('. That is because in `data x /a(1)(2)/`, `a(1)` is
a valid structure constructor.

Also, remove the NamedConstant alternative from DataStmtRepeat. A named
constant is always parsed as a ConstantSubobject so it can never occur.

Original-commit: flang-compiler/f18@04a76b272675d47ec7752420b15976c69a907dab
Reviewed-on: https://github.com/flang-compiler/f18/pull/1012
flang/include/flang/parser/parse-tree.h
flang/lib/parser/Fortran-parsers.cpp