[flang] Change parsing of ambiguous array-spec
authorTim Keith <tkeith@nvidia.com>
Tue, 6 Aug 2019 17:20:16 +0000 (10:20 -0700)
committerTim Keith <tkeith@nvidia.com>
Wed, 7 Aug 2019 17:49:54 +0000 (10:49 -0700)
An array-spec like `(:,:)` (with one or more colons) is either a
deferred-shape-spec-list or an assumed-shape-spec-list and they
can only be distinguished by context that the parser doesn't have.

We were parsing these as assumed-shape-spec-list but they are easier
to deal with if we parse them as deferred-shape-spec-list because
anything that is the latter is also one of the former.

Original-commit: flang-compiler/f18@78c3f3b96f78e45b1b9966b331d8cda691fa39bd
Reviewed-on: https://github.com/flang-compiler/f18/pull/630
Tree-same-pre-rewrite: false

flang/lib/parser/grammar.h

index 803a7c5..6d55d15 100644 (file)
@@ -1088,9 +1088,9 @@ TYPE_PARSER(construct<ExplicitCoshapeSpec>(
 // a need for forced look-ahead.
 TYPE_PARSER(
     construct<ArraySpec>(parenthesized(nonemptyList(explicitShapeSpec))) ||
+    construct<ArraySpec>(parenthesized(deferredShapeSpecList)) ||
     construct<ArraySpec>(
         parenthesized(nonemptyList(Parser<AssumedShapeSpec>{}))) ||
-    construct<ArraySpec>(parenthesized(deferredShapeSpecList)) ||
     construct<ArraySpec>(parenthesized(Parser<AssumedSizeSpec>{})) ||
     construct<ArraySpec>(parenthesized(Parser<ImpliedShapeSpec>{})) ||
     construct<ArraySpec>(parenthesized(Parser<AssumedRankSpec>{})))