diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2019-09-19 08:13:48 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-09-19 08:13:48 +0000 |
commit | 46a500a5cc81138ada165e97e63aed7bea4103e2 (patch) | |
tree | 0ee8d456a508563c64f8736836250e86421007c6 /gcc | |
parent | f5766e3b541a9fb2d4365281f5c9da4f80e9622c (diff) | |
download | gcc-46a500a5cc81138ada165e97e63aed7bea4103e2.zip gcc-46a500a5cc81138ada165e97e63aed7bea4103e2.tar.gz gcc-46a500a5cc81138ada165e97e63aed7bea4103e2.tar.bz2 |
[Ada] Fix run-time segfault with derived access-to-subprogram type
This fixes a segfault at run time for the call to a local subprogram
through an access value if the type of this access value is derived
from an initial access-to-subprogram type and the access value was
originally obtained with the initial type.
2019-09-19 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* sem_ch3.adb (Build_Derived_Access_Type): If this is an access-
to-subprogram type, copy Can_Use_Internal_Rep from the parent.
gcc/testsuite/
* gnat.dg/access9.adb: New testcase.
From-SVN: r275945
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/sem_ch3.adb | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/access9.adb | 20 |
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 6fa4edf..9b05d3e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-09-19 Eric Botcazou <ebotcazou@adacore.com> + + * sem_ch3.adb (Build_Derived_Access_Type): If this is an access- + to-subprogram type, copy Can_Use_Internal_Rep from the parent. + 2019-09-19 Yannick Moy <moy@adacore.com> * gcc-interface/Make-lang.in: Remove references to sem_spark. diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 35be35a..e304e72 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -6723,6 +6723,11 @@ package body Sem_Ch3 is Has_Private_Component (Derived_Type)); Conditional_Delay (Derived_Type, Subt); + if Is_Access_Subprogram_Type (Derived_Type) then + Set_Can_Use_Internal_Rep + (Derived_Type, Can_Use_Internal_Rep (Parent_Type)); + end if; + -- Ada 2005 (AI-231): Set the null-exclusion attribute, and verify -- that it is not redundant. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7cde63d..a927297 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-09-19 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/access9.adb: New testcase. + 2019-09-19 Ed Schonberg <schonberg@adacore.com> * gnat.dg/predicate14.adb, gnat.dg/predicate14.ads: New diff --git a/gcc/testsuite/gnat.dg/access9.adb b/gcc/testsuite/gnat.dg/access9.adb new file mode 100644 index 0000000..d2028c9 --- /dev/null +++ b/gcc/testsuite/gnat.dg/access9.adb @@ -0,0 +1,20 @@ +-- { dg-do run } + +procedure Access9 is + + type A_Type is access procedure; + + type B_Type is new A_Type; + + procedure Invoke (B : B_Type) is + begin + B.all; + end; + + procedure Nested is begin null; end; + + A : A_Type := Nested'Access; + +begin + Invoke (B_Type (A)); +end;
\ No newline at end of file |