[flang-commits] [flang] [flang] Avoid crash on conflicting BIND(C) declaration (PR #231816)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Wed Oct 14 19:58:12 PDT 2026
================
@@ -0,0 +1,8 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+
+module bind_c_conflicting_type_name
+ type :: x
+ end type
+ !ERROR: 'x' is already declared in this scoping unit
+ integer, bind(c) :: x
+end module
----------------
eugeneepshteyn wrote:
(This comment was generated with the help of AI)
This pins only the derived-type case. The same path is taken whenever the name already belongs to anything that cannot carry a binding label, so please also cover the other kinds mentioned in the issue, a generic, a namelist group and a later module procedure, plus the array form as a control, in this same file:
```fortran
module m2
interface g
end interface
!ERROR: 'g' is already declared in this scoping unit
integer, bind(c) :: g
end
module m3
integer :: a
namelist /nl/ a
!ERROR: 'nl' is already declared in this scoping unit
integer, bind(c) :: nl
end
module m4
!ERROR: Declaration of 's' conflicts with its use as module procedure
integer, bind(c) :: s
contains
subroutine s()
end subroutine
end
module m5
type :: t
end type
!ERROR: 't' is already declared in this scoping unit
integer, bind(c) :: t(2)
end
```
The expected messages are the ones the compiler already prints for these declarations without `bind(c)`, and all of them pass with this PR applied.
https://github.com/llvm/llvm-project/pull/231816
More information about the flang-commits
mailing list