This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix bugs related to merging generics during USE
ClosedPublic

Authored by tskeith on Dec 2 2020, 9:16 AM.

Details

Summary

When the same generic name is use-associated from two modules, the
generics are merged into a single one in the current scope. This change
fixes some bugs in that process.

When a generic is merged, it can have two specific procedures with the
same name as the generic (c.f. module m7c in modfile07.f90). We were
disallowing that by checking for duplicate names in the generic rather
than duplicate symbols. Changing namesSeen to symbolsSeen in
ResolveSpecificsInGeneric fixes that.

We weren't including each USE of those generics in the .mod file so in
some cases they were incorrect. Extend GenericDetails to specify all
use-associated symbols that are merged into the generic. This is used to
write out .mod files correctly.

The distinguishability check for specific procedures of a generic
sometimes have to refer to procedures from a use-associated generic in
error messages. In that case we don't have the source location of the
procedure so adapt the message to say where is was use-associated from.
This requires passing the scope through the checks to make that
determination.

Diff Detail

Event Timeline

tskeith created this revision.Dec 2 2020, 9:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2020, 9:16 AM
tskeith requested review of this revision.Dec 2 2020, 9:16 AM

Note that this change depends on https://reviews.llvm.org/D92491

klausler accepted this revision.Dec 2 2020, 10:22 AM
klausler added inline comments.
flang/lib/Semantics/CMakeLists.txt
1 ↗(On Diff #308993)

Should these remain?

flang/lib/Semantics/resolve-names.cpp
2417

clang-tidy's suggested const auto * seems good to me here.

flang/lib/Semantics/symbol.cpp
261

const here too

This revision is now accepted and ready to land.Dec 2 2020, 10:22 AM
tskeith added inline comments.Dec 2 2020, 10:28 AM
flang/lib/Semantics/CMakeLists.txt
1 ↗(On Diff #308993)

That was left over from debugging. I'll get rid of it.

flang/lib/Semantics/resolve-names.cpp
2417

I'll fix those.

PeteSteinfeld accepted this revision.Dec 2 2020, 10:33 AM

It would be good to also fix the lint changes that were automatically suggested.

Aside from my comments, all builds, tests, and looks good.

flang/lib/Semantics/check-declarations.cpp
1903

It would be good to have a test the produces this message.

flang/lib/Semantics/resolve-names.cpp
2422

I realize that his message was there before your change, but it would be good to have a test that produces it.

tskeith updated this revision to Diff 309072.Dec 2 2020, 3:12 PM

Address review comments

flang/lib/Semantics/check-declarations.cpp
1903

This error occurs on line 196 of resolve17.f90.

This revision was landed with ongoing or failed builds.Dec 2 2020, 3:14 PM
This revision was automatically updated to reflect the committed changes.