[flang] Fix source locations for some expressions
authorTim Keith <tkeith@nvidia.com>
Tue, 9 Apr 2019 23:46:36 +0000 (16:46 -0700)
committerTim Keith <tkeith@nvidia.com>
Tue, 9 Apr 2019 23:48:37 +0000 (16:48 -0700)
commit0671857b6980a0107c942f32ed9d618491e8068e
treebe3272ddf8d8389d3c999928bf56d9410a1eda49
parent90b8f222b8c6016e90e3ab4cd19cdb07294cd521
[flang] Fix source locations for some expressions

When expressions are parsed iteratively they weren't getting the correct
source positions. For example, when parsing an `add-operand` as a sequence
of `mult-operand`s separated by `mult-op`.

This shows up when we report an error message referring to this kind
of expression:
```
t.f90:1:11: error: Expected a LOGICAL expression
  if (i * j * k) then
            ^^^
```

The fix is to remember the location of the first operand and then
for each sub-expression (`i * j` and `i * j * k` in this example)
extend its location back to include that first operand.

Original-commit: flang-compiler/f18@e276f11f48f116fa090cf72bcb73199a44d030c3
Reviewed-on: https://github.com/flang-compiler/f18/pull/395
flang/lib/parser/grammar.h