[flang-commits] [flang] [flang] Allow extended char set in `BIND(C, name="...")` (PR #172457)
via flang-commits
flang-commits at lists.llvm.org
Tue Dec 16 08:52:17 PST 2025
foxtran wrote:
> This patch would break any code that is compiling today using a leading period in its name
It would not. If the code wasn't able to compile with older flang, with this patch it is also can not be compiled. Also, gfortran does not allow dot in "name=": https://godbolt.org/z/n7jne4xEc
> I'm not convinced that the reported problem is a real bug, but if other Fortran compilers allow characters in names that we do not, I'd like to see what they are.
Actually, it depends on compiler. I would prefer to think that `bind(C, name="...")` acts like `__asm__("...")`. There dot is allowed:
https://godbolt.org/z/djzYnjjq5
Here you can play which symbols are allowed:
https://godbolt.org/z/fhbc8aaxs
ifx accepts almost everything, except already defined symbols like ".text". nvfortran looks like reproduces behaviour of current flang, gfortran accepts `$` in names.
And some mangling schemes from C++:
Microsoft C++ mangling scheme uses extra `$`, `@`, `?` symbols
Borland C++ mangling scheme uses extra `$`, `@`, `%` symbols
Really old GNU uses extra `.` or `$` symbols
Watcom C++ mangling scheme uses extra `$`, `?`, `.`, `:`, `[`, `]`, `(`, `)` symbols
Rust v0 mangling scheme uses `[A-Za-z0-9_]` symbols.
https://github.com/llvm/llvm-project/pull/172457
More information about the flang-commits
mailing list