[gcc r17-2505] Show details of attr->allocated with -fdump-fortran-original.

Thomas Koenig via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:11264d32461164d5da0660a4a057ab31f8a3e159

commit r17-2505-g11264d32461164d5da0660a4a057ab31f8a3e159
Author: Thomas Koenig <[email protected]>
Date:   Sat Jul 18 10:41:23 2026 +0200

    Show details of attr->allocated with -fdump-fortran-original.
    
    This simple and obvious patch adds output for the var_allocated enum,
    to make the status of where the gfortran thinks a potential allocation
    came from more clear.
    
    Instead of (example from warn_unused_but_set_variable_4.f90)
    
    attributes: (VARIABLE  ALLOCATABLE DIMENSION REFERENCED VALUE-SET(INTENT-OUT) ALLOCATED)
    
    this now displays
    
    attributes: (VARIABLE  ALLOCATABLE DIMENSION REFERENCED VALUE-SET(INTENT-OUT) ALLOCATED(ARG))
    
    No user impact (unless the user is exceptionally curious) and no test
    case.
    
    gcc/fortran/ChangeLog:
    
            PR fortran/126058
            * dump-parse-tree.cc (show_attr): Show details of
            attr->allocated.

Diff:
---
 gcc/fortran/dump-parse-tree.cc | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc
index 19dffe38aed3..eaf6565d0e08 100644
--- a/gcc/fortran/dump-parse-tree.cc
+++ b/gcc/fortran/dump-parse-tree.cc
@@ -1058,8 +1058,20 @@ show_attr (symbol_attribute *attr, const char * module)
       gfc_internal_error ("Wrong value for value_set");
     }
 
-  if (attr->allocated)
-    fputs (" ALLOCATED", dumpfile);
+  switch (attr->allocated)
+    {
+    case ALLOCATED_ARG:
+      fputs (" ALLOCATED(ARG)", dumpfile);
+      break;
+    case ALLOCATED_ALLOCATE_STMT:
+      fputs(" ALLOCATED(ALLOCATE-STMT)", dumpfile);
+      break;
+    case ALLOCATED_ASSIGNMENT:
+      fputs (" ALLOCATED(ASSIGNMENT)", dumpfile);
+      break;
+    default:
+      break;
+    }
 
   switch (attr->value_used)
     {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.