[gfortran] Fix PR 18565

Steve Kargl sgk@troutmask.apl.washington.edu
Thu Jan 27 21:50:00 GMT 2005


On Sun, Jan 23, 2005 at 10:14:45AM -0800, Steve Kargl wrote:
> The problem is well described in the PR, but I'll summarize here.
> The following program is valid Fortran 95.
> 
> program a
>   complex(8) z
>   z = (1.d0,1.d0)
>   print *, conjg(z)
> end program a
> 
> Currently, gfortran will resolve conjg() to use the intrinsic
> function dconjg().  The problem is that if -std=f95 is given
> to gfortran, then dconjg is not included in list of intrinsic
> function because it is not a specific name for the generic 
> function conjg().
> 
> The attached patch has changed intrinsic.c to use _conjg() as
> the double complex version of conjg() for -std=f95 and it 
> makes dconjg() an alias of _conjg() for -std=gnu.
> 
> Now, with the attached patch and if the above program is 
> 
> program a  
>   complex(8) z
>   z = (1.d0,1.d0)
>   print *, dconjg(z)
> end program a
> 
> kargl[226] gfc -o cg -std=f95 cg.f90
> /var/tmp/ccDKKFVt.o(.text+0x4f): In function `MAIN__':
> : undefined reference to `dconjg_'
> collect2: ld returned 1 exit status
> 
> which is acceptable because neither "implicit none" nor 
> "intrinsic dconjg" were used.  If either of these statements
> are included you get error messages from gfortran.
> 
> 2005-01-23  Steven G. Kargl  <kargls@comcast.net>
> 
>        PR 18565
>        * intrinsic.c (add_function): Change dconjg to _conjg and mark
>        with GFC_STD_F95; make dcongj an alias of _conjg marked with
>        GFC_STD_GNU.
> 

All complex(8) intrinsic function that do not have a corresponding
specific name were handled wrong if -std=f95 is given on the 
command line.  The attach patch fixes all of these, not just conjg.

Bootstrapped and regtested on amd64-*-freebsd

2005-01-27  Steven G. Kargl  <kargls@comcast.net>

      PR 18565
      * intrinsic.c (add_function): Permit complex(8) version for generic
      names without corresponding specific names.
-- 
steve
-------------- next part --------------
Index: intrinsic.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/intrinsic.c,v
retrieving revision 1.37
diff -u -r1.37 intrinsic.c
--- intrinsic.c	22 Jan 2005 22:32:06 -0000	1.37
+++ intrinsic.c	27 Jan 2005 21:31:42 -0000
@@ -885,10 +885,11 @@
 	     NULL, gfc_simplify_abs, gfc_resolve_abs,
 	     a, BT_COMPLEX, dz, REQUIRED);
 
-  add_sym_1 ("zabs", 1, 1, BT_REAL, dd, GFC_STD_GNU, 
+  add_sym_1 ("_zabs", 1, 1, BT_REAL, dd, GFC_STD_F95, 
 	     NULL, gfc_simplify_abs, gfc_resolve_abs, 
 	     a, BT_COMPLEX, dd, REQUIRED);
 
+  make_alias ("zabs", GFC_STD_GNU);
   make_alias ("cdabs", GFC_STD_GNU);
 
   make_generic ("abs", GFC_ISYM_ABS, GFC_STD_F77);
@@ -925,10 +926,12 @@
 	     NULL, gfc_simplify_aimag, gfc_resolve_aimag,
 	     z, BT_COMPLEX, dz, REQUIRED);
 
-  add_sym_1 ("dimag", 1, 1, BT_REAL, dd, GFC_STD_GNU, 
+  add_sym_1 ("_dimag", 1, 1, BT_REAL, dd, GFC_STD_F95, 
 	     NULL, gfc_simplify_aimag, gfc_resolve_aimag, 
 	     z, BT_COMPLEX, dd, REQUIRED);
 
+  make_alias ("dimag", GFC_STD_GNU);
+
   make_generic ("aimag", GFC_ISYM_AIMAG, GFC_STD_F77);
 
   add_sym_2 ("aint", 1, 1, BT_REAL, dr, GFC_STD_F77,
@@ -1110,10 +1113,12 @@
 	     NULL, gfc_simplify_conjg, gfc_resolve_conjg,
 	     z, BT_COMPLEX, dz, REQUIRED);
 
-  add_sym_1 ("dconjg", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
+  add_sym_1 ("_dconjg", 1, 1, BT_COMPLEX, dd, GFC_STD_F95,
 	     NULL, gfc_simplify_conjg, gfc_resolve_conjg, 
 	     z, BT_COMPLEX, dd, REQUIRED);
 
+  make_alias ("dconjg", GFC_STD_GNU);
+
   make_generic ("conjg", GFC_ISYM_CONJG, GFC_STD_F77);
 
   add_sym_1 ("cos", 1, 1, BT_REAL, dr, GFC_STD_F77,
@@ -1128,10 +1133,11 @@
 	     NULL, gfc_simplify_cos, gfc_resolve_cos,
 	     x, BT_COMPLEX, dz, REQUIRED);
 
-  add_sym_1 ("zcos", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
+  add_sym_1 ("_zcos", 1, 1, BT_COMPLEX, dd, GFC_STD_F95,
 	     NULL, gfc_simplify_cos, gfc_resolve_cos, 
 	     x, BT_COMPLEX, dd, REQUIRED);
 
+  make_alias ("zcos", GFC_STD_GNU);
   make_alias ("cdcos", GFC_STD_GNU);
 
   make_generic ("cos", GFC_ISYM_COS, GFC_STD_F77);
@@ -1260,10 +1266,11 @@
 	     NULL, gfc_simplify_exp, gfc_resolve_exp,
 	     x, BT_COMPLEX, dz, REQUIRED);
 
-  add_sym_1 ("zexp", 1, 1, BT_COMPLEX, dd,  GFC_STD_GNU,
+  add_sym_1 ("_zexp", 1, 1, BT_COMPLEX, dd,  GFC_STD_F95,
 	     NULL, gfc_simplify_exp, gfc_resolve_exp, 
 	     x, BT_COMPLEX, dd, REQUIRED);
 
+  make_alias ("zexp", GFC_STD_GNU);
   make_alias ("cdexp", GFC_STD_GNU);
 
   make_generic ("exp", GFC_ISYM_EXP, GFC_STD_F77);
@@ -1492,10 +1499,11 @@
 	     NULL, gfc_simplify_log, gfc_resolve_log,
 	     x, BT_COMPLEX, dz, REQUIRED);
 
-  add_sym_1 ("zlog", 1, 1, BT_COMPLEX, dd,  GFC_STD_GNU,
+  add_sym_1 ("_zlog", 1, 1, BT_COMPLEX, dd,  GFC_STD_F95,
 	     NULL, gfc_simplify_log, gfc_resolve_log,
 	     x, BT_COMPLEX, dd, REQUIRED);
 
+  make_alias ("zlog", GFC_STD_GNU);
   make_alias ("cdlog", GFC_STD_GNU);
 
   make_generic ("log", GFC_ISYM_LOG, GFC_STD_F77);
@@ -1832,10 +1840,11 @@
 	     NULL, gfc_simplify_sin, gfc_resolve_sin,
 	     x, BT_COMPLEX, dz, REQUIRED);
 
-  add_sym_1 ("zsin", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
+  add_sym_1 ("_zsin", 1, 1, BT_COMPLEX, dd, GFC_STD_F95,
 	     NULL, gfc_simplify_sin, gfc_resolve_sin,
 	     x, BT_COMPLEX, dd, REQUIRED);
 
+  make_alias ("zsin", GFC_STD_GNU);
   make_alias ("cdsin", GFC_STD_GNU);
 
   make_generic ("sin", GFC_ISYM_SIN, GFC_STD_F77);
@@ -1881,10 +1890,11 @@
 	     NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
 	     x, BT_COMPLEX, dz, REQUIRED);
 
-  add_sym_1 ("zsqrt", 1, 1, BT_COMPLEX, dd, GFC_STD_GNU,
+  add_sym_1 ("_zsqrt", 1, 1, BT_COMPLEX, dd, GFC_STD_F95,
 	     NULL, gfc_simplify_sqrt, gfc_resolve_sqrt,
 	     x, BT_COMPLEX, dd, REQUIRED);
 
+  make_alias ("zsqrt", GFC_STD_GNU);
   make_alias ("cdsqrt", GFC_STD_GNU);
 
   make_generic ("sqrt", GFC_ISYM_SQRT, GFC_STD_F77);


More information about the Gcc-patches mailing list