Re: [patch, Fortran, doc] Mention generating C prototypes from Fortran

2025-01-03 Thread Thomas Koenig

Am 03.01.25 um 14:32 schrieb Sam James:

Thomas Koenig  writes:


Hello world,

I noticed that there is no mention of automatically generating
C prototypes and declarations in the relevant section of
the docs, "Interoperability with C". This patch remedies that.

OK for trunk?

Best regards

Thomas

gcc/fortran/ChangeLog:

* gfortran.texi: New subsection "Generating C prototypes from
Fortran".

[2. text/x-patch; p-unsigned.diff]...


This patch appears empty.


Not only appears, but it actually was empty...

This is a better version.

Best regards

Thomas

diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 4509f080ba4..c1fc6a6fcbd 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -2918,6 +2918,7 @@ C or some other language instead of Fortran, see
 * Interoperable Subroutines and Functions::
 * Working with C Pointers::
 * Further Interoperability of Fortran with C::
+* Generating C prototypes from Fortran::
 @end menu
 
 Since Fortran 2003 (ISO/IEC 1539-1:2004(E)) there is a
@@ -3322,6 +3323,20 @@ are converted to the specified form.  If you need to access GNU Fortran's
 internal array descriptor, you can use the Chasm Language Interoperability
 Tools, @url{http://chasm-interop.sourceforge.net/}.
 
+@node Generating C prototypes from Fortran
+@subsection Generating C prototypes from Fortran
+@cindex prototypes
+@cindex C prototypes
+The options @option{-fc-prototypes} can be used to write out C
+declatations and function prototypes for @code{BIND(C)} entities.
+The same can be done for writing out prototypes for external
+procedures using @option{-fc-prototypes-external},
+@pxref{Interoperability Options}.
+
+Standard Fortran does not specify an interoperable type for C's
+@code{unsigned} integer types.  For interoperability with unsigned
+types, GNU Fortran provides unsigned integers, @pxref{Unsigned integers}.
+
 @node GNU Fortran Compiler Directives
 @section GNU Fortran Compiler Directives
 @cindex GNU Fortran Compiler Directives


[patch, Fortran, doc] Mention generating C prototypes from Fortran

2025-01-03 Thread Thomas Koenig

Hello world,

I noticed that there is no mention of automatically generating
C prototypes and declarations in the relevant section of
the docs, "Interoperability with C". This patch remedies that.

OK for trunk?

Best regards

Thomas

gcc/fortran/ChangeLog:

* gfortran.texi: New subsection "Generating C prototypes from
Fortran".



Re: [PATCH] Fortran: Cray pointer comparison wrongly optimized away [PR106692]

2025-01-03 Thread Harald Anlauf

Hi Jerry!

Am 03.01.25 um 05:21 schrieb Jerry D:

On 1/2/25 12:04 PM, Harald Anlauf wrote:

Dear all,

this patch addresses overeager optimization of Cray pointers when
used in comparisons.  Cray pointers are non-standard, and odd in a
sense that they were introduced before modern Fortran pointers.
Comparisons with e.g. a "NULL" pointer are actually comparisons
with integer zero etc., which means that while they are references
they can actually be "NULL" to mimic a disassociated pointer.
The only solution I could find was treating them locally as volatile
when used in a comparison.  If someone has a better solution, please
share!

As this is a local solution, and a real-world legacy code using Cray
pointers would likely never use such a test in a vectorizable loop,
I expect negligible (performance and code-size) impact.

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

This PR is marked as a regression (since gcc-7), is this OK for
a (limited?) backport?

Thanks,
Harald



The hack is fairly isolated and simple. The problem is a quirk from the
past. The only way to expose an issue is to get it into the real world
and see if anyone notices a problem.


I do not have access to any code using Cray pointers beyond what is in
the testsuite.  They might get used in some SPEC benchmark, we'll see.


OK for trunk and maybe 14.  If you think farther back, up to you.


Pushed to mainline as r15-6545 so far.

Thanks for the feedback!

Harald


Jerry





Re: [patch, Fortran, doc] Mention generating C prototypes from Fortran

2025-01-03 Thread Sam James
Thomas Koenig  writes:

> Hello world,
>
> I noticed that there is no mention of automatically generating
> C prototypes and declarations in the relevant section of
> the docs, "Interoperability with C". This patch remedies that.
>
> OK for trunk?
>
> Best regards
>
>   Thomas
>
> gcc/fortran/ChangeLog:
>
>   * gfortran.texi: New subsection "Generating C prototypes from
>   Fortran".
>
> [2. text/x-patch; p-unsigned.diff]...

This patch appears empty.


Re: [patch, Fortran, doc] Mention generating C prototypes from Fortran

2025-01-03 Thread Jerry D

On 1/3/25 6:21 AM, Thomas Koenig wrote:

Am 03.01.25 um 14:32 schrieb Sam James:

Thomas Koenig  writes:


Hello world,

I noticed that there is no mention of automatically generating
C prototypes and declarations in the relevant section of
the docs, "Interoperability with C". This patch remedies that.

OK for trunk?

Best regards

Thomas

gcc/fortran/ChangeLog:

* gfortran.texi: New subsection "Generating C prototypes from
Fortran".

[2. text/x-patch; p-unsigned.diff]...


This patch appears empty.


Not only appears, but it actually was empty...

This is a better version.

Best regards

 Thomas


OK by me.

cheers,

Jerry