Fortran: Fix regression caused by PR37336 patch [PR109206]
authorPaul Thomas <pault@gcc.gnu.org>
Tue, 21 Mar 2023 06:28:07 +0000 (06:28 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Tue, 21 Mar 2023 06:28:07 +0000 (06:28 +0000)
2023-03-21  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/109206
* trans-array.cc (gfc_trans_array_constructor_value): Correct
incorrect setting of typespec.

gcc/fortran/trans-array.cc

index 7bc0e03..41661b4 100644 (file)
@@ -2046,6 +2046,7 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock,
   tree shadow_loopvar = NULL_TREE;
   gfc_saved_var saved_loopvar;
 
+  ts.type = BT_UNKNOWN;
   mpz_init (size);
   for (c = gfc_constructor_first (base); c; c = gfc_constructor_next (c))
     {
@@ -2204,7 +2205,9 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock,
               gfc_add_modify (&body, *offsetvar, *poffset);
               *poffset = *offsetvar;
             }
-         ts = c->expr->ts;
+
+         if (!c->iterator)
+           ts = c->expr->ts;
        }
 
       /* The frontend should already have done any expansions