[flang] Fix bug in adding symbols to parse tree.
authorTim Keith <tkeith@nvidia.com>
Tue, 19 Jun 2018 21:59:41 +0000 (14:59 -0700)
committerTim Keith <tkeith@nvidia.com>
Tue, 19 Jun 2018 21:59:41 +0000 (14:59 -0700)
commit0d701085e0cda1e1d685891c9fbf8fa4030a12a5
tree1bcf5df5ebde965e34f0b7aea2440877d2bb4280
parent0d3fda524b83d282e17d4fcfc2e9826d9142ccd0
[flang] Fix bug in adding symbols to parse tree.

We were collecting symbols in a map of SourceName to Symbol*.
This is wrong because sometimes different occurrences of a name
map to different symbols (e.g. in different scopes).
SourceName::begin() is unique for each occurrence so use that
as the map key instead.

The problem can be reproduced by running:
`f18 -fdebug-resolve-names -fparse-only -fdebug-dump-parse-tree`
on the following source. The two symbols 'i' should have different
types and they were both coming out as INTEGER because they both
pointed to the first symbol for 'i'.

```
module m
  integer :: i
contains
  subroutine s
    real :: i
  end
end
```

Original-commit: flang-compiler/f18@a165c717ff20d3ccca334b91fa538f54b54071cf
Reviewed-on: https://github.com/flang-compiler/f18/pull/107
Tree-same-pre-rewrite: false
flang/lib/semantics/rewrite-parse-tree.cc