[Bug fortran/50960] [OOP] vtables not marked as constant

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 7 22:59:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50960

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |janus at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #20 from janus at gcc dot gnu.org 2011-11-07 22:57:46 UTC ---
(In reply to comment #17)
> Missing handling of se.want_pointer at least here:
> 
> void
> gfc_conv_structure (gfc_se * se, gfc_expr * expr, int init)
> {
> ...
>   if (!init)
>     {
>       /* Create a temporary variable and fill it in.  */
>       se->expr = gfc_create_var (type, expr->ts.u.derived->name);
>       tmp = gfc_trans_structure_assign (se->expr, expr);
>       gfc_add_expr_to_block (&se->pre, tmp);
>       return;
> 
> but what's the desire of the caller?  Is it to get &expr?  Something
> seems to be seriously wrong.

Indeed. The funny thing is that we have to deal with an EXPR_STRUCTURE at all,
not with an EXPR_VARIABLE. This is because the __vtab_... variable is replaced
with its value (which happens in simplify_parameter_variable). Of course this
should not happen, and the trouble starts when we try to take the address of
the EXPR_STRUCTURE ...

Here is a patch which prevents simplifying a parameter variable which is a
vtab:

Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c    (revision 181106)
+++ gcc/fortran/expr.c    (working copy)
@@ -1883,7 +1883,8 @@ gfc_simplify_expr (gfc_expr *p, int type)
      initialization expression, or we want a subsection.  */
       if (p->symtree->n.sym->attr.flavor == FL_PARAMETER
       && (gfc_init_expr_flag || p->ref
-          || p->symtree->n.sym->value->expr_type != EXPR_ARRAY))
+          || p->symtree->n.sym->value->expr_type != EXPR_ARRAY)
+      && !p->symtree->n.sym->attr.vtab)
     {
       if (simplify_parameter_variable (p, type) == FAILURE)
         return FAILURE;


With this, the extends_type_of* tests work as expected. So: No more
regressions!



More information about the Gcc-bugs mailing list