https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109322
--- Comment #12 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
One additional point. Using -fdump-fortran-original on
the original test case, one finds
symtree: 'Bar' || symbol: 'bar'
type spec : (UNKNOWN 0 C_INTEROP)
attributes: (DERIVED PUBLIC BIND(C))
components:
(a (INTEGER 8 C_INTEROP) ())
(b (INTEGER 4 C_INTEROP) ())
(c (INTEGER 2 C_INTEROP) ())
(d (INTEGER 1 C_INTEROP) ())
etc. The compiler currently does not keep track which of the
differently-named versions has been used, it just records the
resulting KIND number.
To change this would be a major rewrite, possibly touching a lot
of places.