https://gcc.gnu.org/g:6e34a4c82deae0f0582b6c6abdca69034f6e20db

commit r17-1717-g6e34a4c82deae0f0582b6c6abdca69034f6e20db
Author: Georg-Johann Lay <[email protected]>
Date:   Sat Jun 20 10:49:31 2026 +0200

    AVR: Use tree.h's strip_array_types.
    
    gcc/
            * config/avr/avr.cc (avr_progmem_p): Use strip_array_types to
            peel off ARRAY_TYPEs.
            (avr_nonconst_pointer_addrspace): Same.
            (avr_insert_attributes): Same.
            (avr_decl_maybe_lds_p): Same.

Diff:
---
 gcc/config/avr/avr.cc | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 38713225489a..3cf43e99f0bf 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -11898,11 +11898,7 @@ avr_progmem_p (tree decl, tree attributes)
       != lookup_attribute ("progmem", attributes))
     return -1;
 
-  tree a = decl;
-
-  do
-    a = TREE_TYPE (a);
-  while (TREE_CODE (a) == ARRAY_TYPE);
+  tree a = strip_array_types (TREE_TYPE (decl));
 
   if (a == error_mark_node)
     return 0;
@@ -11933,8 +11929,7 @@ avr_decl_absdata_p (tree decl, tree attributes)
 static addr_space_t
 avr_nonconst_pointer_addrspace (tree typ)
 {
-  while (ARRAY_TYPE == TREE_CODE (typ))
-    typ = TREE_TYPE (typ);
+  typ = strip_array_types (typ);
 
   if (POINTER_TYPE_P (typ))
     {
@@ -11947,8 +11942,7 @@ avr_nonconst_pointer_addrspace (tree typ)
 
       /* "Ordinary" pointers... */
 
-      while (TREE_CODE (target) == ARRAY_TYPE)
-       target = TREE_TYPE (target);
+      target = strip_array_types (target);
 
       /* Pointers to non-generic address space must be const.  */
 
@@ -12171,14 +12165,10 @@ avr_insert_attributes (tree node, tree *attributes)
       && (TREE_STATIC (node) || DECL_EXTERNAL (node))
       && avr_progmem_p (node, *attributes))
     {
-      tree node0 = node;
-
       /* For C++, we have to peel arrays in order to get correct
         determination of readonlyness.  */
 
-      do
-       node0 = TREE_TYPE (node0);
-      while (TREE_CODE (node0) == ARRAY_TYPE);
+      tree node0 = strip_array_types (TREE_TYPE (node));
 
       if (error_mark_node == node0)
        return;
@@ -12452,9 +12442,7 @@ avr_decl_maybe_lds_p (tree node)
 
   // C++ requires peeling arrays.
 
-  do
-    node = TREE_TYPE (node);
-  while (ARRAY_TYPE == TREE_CODE (node));
+  node = strip_array_types (TREE_TYPE (node));
 
   return (node != error_mark_node
          && !TYPE_READONLY (node));

Reply via email to