[Bug fortran/100914] Bind(c): errors handling complex

2021-10-21 Thread sandra at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

sandra at gcc dot gnu.org changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #9 from sandra at gcc dot gnu.org ---
I think it's safe to close this issue now.  The testcase is in and still passes
after Tobias's changes.

[Bug fortran/100914] Bind(c): errors handling complex

2021-09-02 Thread sandra at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

sandra at gcc dot gnu.org changed:

   What|Removed |Added

 CC||sandra at gcc dot gnu.org

--- Comment #8 from sandra at gcc dot gnu.org ---
I think this bug has been fixed by commit 

93b6b2f614eb692d1d8126ec6cb946984a9d01d7

but as Tobias is presently rewriting the front-end code to build CFI
descriptors directly instead of calling a library function, we should be
careful that this bug doesn't creep back in.

[Bug fortran/100914] Bind(c): errors handling complex

2021-09-02 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Sandra Loosemore :

https://gcc.gnu.org/g:93b6b2f614eb692d1d8126ec6cb946984a9d01d7

commit r12-3321-g93b6b2f614eb692d1d8126ec6cb946984a9d01d7
Author: Sandra Loosemore 
Date:   Wed Aug 18 07:22:03 2021 -0700

libgfortran: Further fixes for GFC/CFI descriptor conversions.

This patch is for:
PR100907 - Bind(c): failure handling wide character
PR100911 - Bind(c): failure handling C_PTR
PR100914 - Bind(c): errors handling complex
PR100915 - Bind(c): failure handling C_FUNPTR
PR100917 - Bind(c): errors handling long double real

All of these problems are related to the GFC descriptors constructed
by the Fortran front end containing ambigous or incomplete
information.  This patch does not attempt to change the GFC data
structure or the front end, and only makes the runtime interpret it in
more reasonable ways.  It's not a complete fix for any of the listed
issues.

The Fortran front end does not distinguish between C_PTR and
C_FUNPTR, mapping both onto BT_VOID.  That is what this patch does also.

The other bugs are related to GFC descriptors only containing elem_len
and not kind.  For complex types, the elem_len needs to be divided by
2 and then mapped onto a real kind.  On x86 targets, the kind
corresponding to C long double is different than its elem_len; since
we cannot accurately disambiguate between a 16-byte kind 10 long
double from __float128, this patch arbitrarily prefers to interpret that as
the standard long double type rather than the GNU extension.

Similarly, for character types, the GFC descriptor cannot distinguish
between character(kind=c_char, len=4) and character(kind=ucs4, len=1).
But since the front end currently rejects anything other than len=1
(PR92482) this patch uses the latter interpretation.

2021-09-01  Sandra Loosemore  
José Rui Faustino de Sousa  

gcc/testsuite/
PR fortran/100911
PR fortran/100915
PR fortran/100916
* gfortran.dg/PR100911.c: New file.
* gfortran.dg/PR100911.f90: New file.
* gfortran.dg/PR100914.c: New file.
* gfortran.dg/PR100914.f90: New file.
* gfortran.dg/PR100915.c: New file.
* gfortran.dg/PR100915.f90: New file.

libgfortran/
PR fortran/100907
PR fortran/100911
PR fortran/100914
PR fortran/100915
PR fortran/100917
* ISO_Fortran_binding-1-tmpl.h (CFI_type_cfunptr): Make equivalent
to CFI_type_cptr.
* runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc): Fix
handling of CFI_type_cptr and CFI_type_cfunptr.  Additional error
checking and code cleanup.
(gfc_desc_to_cfi_desc): Likewise.  Also correct kind mapping
for character, complex, and long double types.

[Bug fortran/100914] Bind(c): errors handling complex

2021-06-18 Thread dominiq at lps dot ens.fr via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|WAITING |ASSIGNED

[Bug fortran/100914] Bind(c): errors handling complex

2021-06-13 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

--- Comment #6 from José Rui Faustino de Sousa  ---
Created attachment 50998
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50998=edit
Patch and changelog

[Bug fortran/100914] Bind(c): errors handling complex

2021-06-13 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

--- Comment #5 from José Rui Faustino de Sousa  ---
Patch posted:

https://gcc.gnu.org/pipermail/fortran/2021-June/056154.html

[Bug fortran/100914] Bind(c): errors handling complex

2021-06-05 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

--- Comment #4 from José Rui Faustino de Sousa  ---
Created attachment 50956
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50956=edit
Missing macros

[Bug fortran/100914] Bind(c): errors handling complex

2021-06-05 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

--- Comment #3 from José Rui Faustino de Sousa  ---
This is the same problem as in PR100910.

I will attach an updated file.

Thank you very much.

Best regards,
José Rui

[Bug fortran/100914] Bind(c): errors handling complex

2021-06-05 Thread dominiq at lps dot ens.fr via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

Dominique d'Humieres  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2021-06-05
 Status|UNCONFIRMED |WAITING

--- Comment #2 from Dominique d'Humieres  ---
On my system I get

% gfc pr100914.f90 pr100914.c
pr100914.c: In function 'c_vrfy_float_complex':
pr100914.c:61:22: warning: implicit declaration of function 'CMPLXF'
[-Wimplicit-function-declaration]
   61 | if ((cabsf (*ip-(CMPLXF((float)(i+1),
(float)(2*(i+1)>(float)0.0))
  |  ^~
pr100914.c: In function 'c_vrfy_double_complex':
pr100914.c:98:21: warning: implicit declaration of function 'CMPLX'
[-Wimplicit-function-declaration]
   98 | if ((cabs (*ip-(CMPLX((double)(i+1),
(double)(2*(i+1)>(double)0.0))
  | ^
Undefined symbols for architecture x86_64:
  "_CMPLX", referenced from:
  _c_vrfy_double_complex in ccFYXXYa.o
  _c_vrfy_float128_complex in ccFYXXYa.o
  "_CMPLXF", referenced from:
  _c_vrfy_float_complex in ccFYXXYa.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

[Bug fortran/100914] Bind(c): errors handling complex

2021-06-04 Thread jrfsousa at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100914

--- Comment #1 from José Rui Faustino de Sousa  ---
Created attachment 50940
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50940=edit
C code for bind(c)