[Bug fortran/47023] C_Sizeof: Rejects valid code
janus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Oct 18 12:18:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47023
--- Comment #20 from janus at gcc dot gnu.org 2011-10-18 12:17:42 UTC ---
(In reply to comment #19)
> > > * reject proc-pointers for SIZEOF (comment #7)
I think one could also allow them, but then the implementation of SIZEOF needs
to be fixed to give the size of the pointer.
Draft patch:
Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c (revision 180129)
+++ gcc/fortran/trans-intrinsic.c (working copy)
@@ -5088,8 +5088,11 @@ gfc_conv_intrinsic_sizeof (gfc_se *se, gfc_expr *e
gfc_conv_expr_reference (&argse, arg);
- type = TREE_TYPE (build_fold_indirect_ref_loc (input_location,
- argse.expr));
+ if (arg->ts.type == BT_PROCEDURE)
+ type = TREE_TYPE (argse.expr);
+ else
+ type = TREE_TYPE (build_fold_indirect_ref_loc (input_location,
+ argse.expr));
/* Obtain the source word length. */
if (arg->ts.type == BT_CHARACTER)
With this the test case in comment #19 gives:
8
8
4
which is ok, apart from the fact that sizeof(proc) should be rejected.
More information about the Gcc-bugs
mailing list