forked from OSchip/llvm-project
[flang] Fix one regression failure related to BIND(C) statement
For BIND(C) statement, two common block with the same name can have the same bind name. Fix the regression failure by adding this check. Also add the regression tests. Co-authored-by: Jean Perier <jperier@nvidia.com> Reviewed By: clementval Differential Revision: https://reviews.llvm.org/D127841
This commit is contained in:
parent
9c8fe394cf
commit
60e359943b
|
@ -1892,7 +1892,10 @@ void CheckHelper::CheckBindC(const Symbol &symbol) {
|
|||
auto pair{bindC_.emplace(*name, symbol)};
|
||||
if (!pair.second) {
|
||||
const Symbol &other{*pair.first->second};
|
||||
if (DefinesBindCName(other) && !context_.HasError(other)) {
|
||||
// Two common blocks with the same name can have the same BIND(C) name.
|
||||
if ((!symbol.has<CommonBlockDetails>() ||
|
||||
symbol.name() != other.name()) &&
|
||||
DefinesBindCName(other) && !context_.HasError(other)) {
|
||||
if (auto *msg{messages_.Say(symbol.name(),
|
||||
"Two symbols have the same BIND(C) name '%s'"_err_en_US,
|
||||
*name)}) {
|
||||
|
|
|
@ -48,3 +48,24 @@ module m
|
|||
integer, bind(c, name="ss2") :: s5
|
||||
|
||||
end
|
||||
|
||||
subroutine common1()
|
||||
real :: x
|
||||
common /com/ x
|
||||
bind(c, name='xcom') /com/ ! no error
|
||||
end subroutine
|
||||
|
||||
subroutine common2()
|
||||
real :: x
|
||||
common /com/ x
|
||||
bind(c, name='xcom') /com/ ! no error
|
||||
end subroutine
|
||||
|
||||
module a
|
||||
integer, bind(c, name="int") :: i
|
||||
end module
|
||||
|
||||
module b
|
||||
!ERROR: Two symbols have the same BIND(C) name 'int'
|
||||
integer, bind(c, name="int") :: i
|
||||
end module
|
||||
|
|
Loading…
Reference in New Issue