https://gcc.gnu.org/g:ca157c84903b7e4e58a95aff75418c309ee31e4a

commit ca157c84903b7e4e58a95aff75418c309ee31e4a
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Tue Feb 4 20:28:06 2025 +0100

    Correction régression dummy_3.f90

Diff:
---
 gcc/fortran/trans-array.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 32e03509b8c6..90eafe7ffe18 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -680,6 +680,7 @@ public:
   virtual bool is_initialization () const { return false; }
   virtual bool initialize_data () const { return false; }
   virtual bool set_span () const { return false; }
+  virtual bool set_token () const { return true; }
   virtual tree get_data_value () const { return NULL_TREE; }
   virtual bt get_type_type (const gfc_typespec &) const { return BT_UNKNOWN; }
   virtual tree get_length (gfc_typespec *ts) const { return get_size_info 
(*ts); }
@@ -751,19 +752,21 @@ private:
   gfc_typespec *ts;
   tree value;
   bool use_tree_type_;
+  bool clear_token;
   tree get_elt_type () const;
 
 public:
   scalar_value(gfc_typespec &arg_ts, tree arg_value)
-    : initialisation(true), ts(&arg_ts), value(arg_value), use_tree_type_ 
(false) { }
+    : initialisation(true), ts(&arg_ts), value(arg_value), use_tree_type_ 
(false), clear_token(true) { }
   scalar_value(tree arg_value)
-    : initialisation(true), ts(nullptr), value(arg_value), use_tree_type_ 
(true) { }
+    : initialisation(true), ts(nullptr), value(arg_value), use_tree_type_ 
(true), clear_token(false) { }
   virtual bool is_initialization () const { return initialisation; }
   virtual bool initialize_data () const { return true; }
   virtual tree get_data_value () const;
   virtual gfc_typespec *get_type () const { return ts; }
   virtual bool set_span () const { return true; }
   virtual bool use_tree_type () const { return use_tree_type_; }
+  virtual bool set_token () const { return clear_token; }
   virtual bt get_type_type (const gfc_typespec &) const;
   virtual tree get_length (gfc_typespec *ts) const;
 };
@@ -918,7 +921,8 @@ get_descriptor_init (tree type, gfc_typespec *ts, int rank,
       CONSTRUCTOR_APPEND_ELT (v, span_field, span_value);
     }
 
-  if (flag_coarray == GFC_FCOARRAY_LIB && attr->codimension)
+  if (flag_coarray == GFC_FCOARRAY_LIB && attr->codimension
+      && init.set_token ())
     {
       /* Declare the variable static so its array descriptor stays present
         after leaving the scope.  It may still be accessed through another

Reply via email to