As Fortran 2018 C802 and C873, if bind name is specified, there can only
be only one entity. The check for common block is missed before. As
Fortran 2018 8.5.5 point 2, the bind name is one identifier, which is
unique. That is, one entity can not have multiple bind names. Also add
this check.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
flang/lib/Semantics/check-declarations.cpp | ||
---|---|---|
380 | Would be less confusing if you reversed the test and deleted the return statement. | |
flang/lib/Semantics/resolve-names.cpp | ||
1677 | This is written in a confusing style. Try this: auto oldName{symbol.GetBindName()}; symbol.SetBindName(std::move(*label)); if (oldName) { if (auto newName{symbol.GetBindName()}) { if (*oldName != *newName) { // error } } } |
Addressed the comments from @klausler .
flang/lib/Semantics/check-declarations.cpp | ||
---|---|---|
380 | Fixed. | |
flang/lib/Semantics/resolve-names.cpp | ||
1677 | symbol.GetBindName() returns the pointer to oldName. After symbol.SetBindName, oldName points to the new symbol.GetBindName(). So oldName must store the value of bind name. But change the style as suggested. |
flang/lib/Semantics/resolve-names.cpp | ||
---|---|---|
1685 | if (std::string newBindName* = symbol.GetBindName()) { ... } |
This program no longer compiles after this patch:
subroutine subr
bind(c,name="foo") /blk/ integer j common /blk/ j print *, j
end
program main
bind(c,name="foo") /blk/ integer j common /blk/ j j = 123 call subr
end
Thanks for this. @jeanPerier has sent me one similar regression test yesterday and it has been fixed by https://reviews.llvm.org/rG60e359943bfc22155cd239c9b40b3e4c41026915.
Would be less confusing if you reversed the test and deleted the return statement.