This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran, committed] Fix type-safety issues was: Re: [gfortran]Fix PR 20178: Implement g77 / f2c calling conventions


Tobias Schlüter wrote:
> gfc_trans_scalar_assign explicitly converts the assignment:
>       gfc_add_modify_expr (&block, lse->expr,
> 			   fold_convert (TREE_TYPE (lse->expr), rse->expr));
> which is why this works.  Admittedly, this might be papering over other bugs.
>  I'm currently running the testsuite with the call to fold_convert removed to
> see what happens.  So far it seems to hold up.

But it didn't hold up much longer than it took me to click on send :(

Complex constants were not given the correct tree type which made a number of
testcases fail.  Fixed by below patch, which I will commit to the mainline as
obvious after it finishes testing in a clean tree.

There remains a type-safety issue which is that
  I = NULL()
where I is _not_ a pointer will not compile without the call to fold_const.
Actually, this statement doesn't give the expected segfault because the result
from NULL() isn't dereferenced.  While it would be easy to introduce the
dereference,  and while I couldn't convince myself that this is illegal, I'd
vote for removing this, as I also couldn't convince myself that this is legal.
 The table in 7.1.4.1 of the draft F95 standard seems to indicate quite
strongly that this is not allowed.  I'd vote for removing this 'feature'
(which was introduced as resolution to PR 15754 BTW).

With these two issues resolved the testsuite runs cleanly with the call to
fold_convert removed.

- Tobi

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/ChangeLog,v
retrieving revision 1.343
diff -u -p -r1.343 ChangeLog
--- ChangeLog   4 Mar 2005 21:03:28 -0000       1.343
+++ ChangeLog   5 Mar 2005 19:59:20 -0000
@@ -1,3 +1,8 @@
+2005-03-05  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       * trans-const.c (gfc_conv_constant_to_tree): Use correct tree
+       type for COMPLEX constants.
+
 2005-03-04  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>

        PR fortran/19673
Index: trans-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-const.c,v
retrieving revision 1.21
diff -u -p -r1.21 trans-const.c
--- trans-const.c       22 Jan 2005 00:29:33 -0000      1.21
+++ trans-const.c       5 Mar 2005 19:59:20 -0000
@@ -316,7 +316,8 @@ gfc_conv_constant_to_tree (gfc_expr * ex
        tree imag = gfc_conv_mpfr_to_tree (expr->value.complex.i,
                                          expr->ts.kind);

-       return build_complex (NULL_TREE, real, imag);
+       return build_complex (gfc_typenode_for_spec (&expr->ts),
+                             real, imag);
       }

     case BT_CHARACTER:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]