trans.h (struct gfc_ss_info): Move can_be_null_ref component from the data::scalar...
authorMikael Morin <mikael@gcc.gnu.org>
Sun, 4 Mar 2012 20:46:55 +0000 (20:46 +0000)
committerMikael Morin <mikael@gcc.gnu.org>
Sun, 4 Mar 2012 20:46:55 +0000 (20:46 +0000)
fortran/
* trans.h (struct gfc_ss_info): Move can_be_null_ref component from
the data::scalar subcomponent to the toplevel.
* trans-expr.c (gfc_conv_expr): Update component reference.
* trans-array.c (gfc_add_loop_ss_code): Ditto.
(gfc_walk_elemental_function_args): Ditto.  Move the conditional setting
the field out of the scalar-only block.

From-SVN: r184893

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/fortran/trans-expr.c
gcc/fortran/trans.h

index 3a072e0a9b0155366b2c24630a5e767ab14bac75..961bd4e18f29b0183515c7b3db2e30e7f20715e3 100644 (file)
@@ -1,3 +1,12 @@
+2012-03-04  Mikael Morin  <mikael@gcc.gnu.org>
+
+       * trans.h (struct gfc_ss_info): Move can_be_null_ref component from
+       the data::scalar subcomponent to the toplevel.
+       * trans-expr.c (gfc_conv_expr): Update component reference.
+       * trans-array.c (gfc_add_loop_ss_code): Ditto.
+       (gfc_walk_elemental_function_args): Ditto.  Move the conditional setting
+       the field out of the scalar-only block.
+
 2012-03-04  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/36160
index bbe5afeebbf3891a0de586c3c44947f132647f91..b54c95b4087d2e4cd682b55eefb40e1c818ee09a 100644 (file)
@@ -2448,7 +2448,7 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript,
        case GFC_SS_REFERENCE:
          /* Scalar argument to elemental procedure.  */
          gfc_init_se (&se, NULL);
-         if (ss_info->data.scalar.can_be_null_ref)
+         if (ss_info->can_be_null_ref)
            {
              /* If the actual argument can be absent (in other words, it can
                 be a NULL reference), don't try to evaluate it; pass instead
@@ -8493,17 +8493,18 @@ gfc_walk_elemental_function_args (gfc_ss * ss, gfc_actual_arglist *arg,
          newss = gfc_get_scalar_ss (head, arg->expr);
          newss->info->type = type;
 
-         if (dummy_arg != NULL
-             && dummy_arg->sym->attr.optional
-             && arg->expr->expr_type == EXPR_VARIABLE
-             && (gfc_expr_attr (arg->expr).optional
-                 || gfc_expr_attr (arg->expr).allocatable
-                 || gfc_expr_attr (arg->expr).pointer))
-           newss->info->data.scalar.can_be_null_ref = true;
        }
       else
        scalar = 0;
 
+      if (dummy_arg != NULL
+         && dummy_arg->sym->attr.optional
+         && arg->expr->expr_type == EXPR_VARIABLE
+         && (gfc_expr_attr (arg->expr).optional
+             || gfc_expr_attr (arg->expr).allocatable
+             || gfc_expr_attr (arg->expr).pointer))
+       newss->info->can_be_null_ref = true;
+
       head = newss;
       if (!tail)
         {
index d69399ce08fcf5fbc3b8088329b92722599f2fa5..5fb95b1765324c359bf115f1cb9d310c96b7eee8 100644 (file)
@@ -5458,7 +5458,7 @@ gfc_conv_expr (gfc_se * se, gfc_expr * expr)
       se->expr = ss_info->data.scalar.value;
       /* If the reference can be NULL, the value field contains the reference,
         not the value the reference points to (see gfc_add_loop_ss_code).  */
-      if (ss_info->data.scalar.can_be_null_ref)
+      if (ss_info->can_be_null_ref)
        se->expr = build_fold_indirect_ref_loc (input_location, se->expr);
 
       se->string_length = ss_info->string_length;
index e685a84c388154156e97865373d6c3b6e20f66ac..8beefe10d278709b312c97113fd605e70515365c 100644 (file)
@@ -198,9 +198,6 @@ typedef struct gfc_ss_info
     struct
     {
       tree value;
-      /* Tells whether the reference can be null in the GFC_SS_REFERENCE case.
-        Used to handle elemental procedures' optional arguments.  */
-      bool can_be_null_ref;
     }
     scalar;
 
@@ -223,6 +220,11 @@ typedef struct gfc_ss_info
 
   /* Suppresses precalculation of scalars in WHERE assignments.  */
   unsigned where:1;
+
+  /* Tells whether the SS is for an actual argument which can be a NULL
+     reference.  In other words, the associated dummy argument is OPTIONAL.
+     Used to handle elemental procedures.  */
+  bool can_be_null_ref;
 }
 gfc_ss_info;