[COMMITTED,32/51] ada: Linker_Section not inherited by object from unconstrained parent subtype

Message ID 20260602084541.3829876-32-poulhies@adacore.com
State Committed
Commit 280e68a6d3fd5045e6c1b1f6937f00c81333a307
Headers
Series [COMMITTED,01/51] ada: Rename Private_Component function |

Commit Message

Marc Poulhiès June 2, 2026, 8:45 a.m. UTC
  From: Gary Dismukes <dismukes@adacore.com>

In the case of an object_declaration with a subtype_indication
whose subtype_mark denotes an unconstrained parent subtype (like
"type Unconstrained_String is new String") that itself specifies
the Linker_Section aspect or pragma, the object is not being inherited
from the type like it should be, and so will not be allocated in
the section specified by the aspect or pragma.

gcc/ada/ChangeLog:

	* sem_ch3.adb (Copy_Parent_Attributes): Inherit Linker_Section_Pragma.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch3.adb | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 1f8d86eb631..e07d24c1565 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -5800,6 +5800,8 @@  package body Sem_Ch3 is
          Set_Treat_As_Volatile (Id, Treat_As_Volatile (T));
          Set_Is_Generic_Type (Id, Is_Generic_Type (Base_Type (T)));
          Set_Convention (Id, Convention (T));
+         Set_Linker_Section_Pragma
+           (Id, Linker_Section_Pragma (Base_Type (T)));
       end Copy_Parent_Attributes;
 
    --  Start of processing for Analyze_Subtype_Declaration