This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/47023] C_Sizeof: Rejects valid code
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 18 Oct 2011 12:17:42 +0000
- Subject: [Bug fortran/47023] C_Sizeof: Rejects valid code
- Auto-submitted: auto-generated
- References: <bug-47023-4@http.gcc.gnu.org/bugzilla/>
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.