diff options
author | Ed Schonberg <schonberg@adacore.com> | 2018-12-11 11:11:00 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-12-11 11:11:00 +0000 |
commit | 5e366628853651e5d7a98e7bc12f5fb7746ce993 (patch) | |
tree | 4ac1f440ff6cb94ae1ee87f2653e8177773edad1 /gcc/ada | |
parent | 6b6a0f02ab7012daebd62726066b827fbdfa62f9 (diff) | |
download | gcc-5e366628853651e5d7a98e7bc12f5fb7746ce993.zip gcc-5e366628853651e5d7a98e7bc12f5fb7746ce993.tar.gz gcc-5e366628853651e5d7a98e7bc12f5fb7746ce993.tar.bz2 |
[Ada] Crash on compilation unit function that builds in place
This patch fixes a crash on a function that builds its limited result in
place. Previously this was handled properly only if the function was a
child unit.
2018-12-11 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch3.adb (Build_Itype_Reference): Handle properly an itype
reference created for a function that is a compilation unit, for
example if the function builds in place an object of a limited
type.
gcc/testsuite/
* gnat.dg/bip_cu.adb, gnat.dg/bip_cu_constructor.adb,
gnat.dg/bip_cu_constructor.ads, gnat.dg/bip_cu_t.adb,
gnat.dg/bip_cu_t.ads: New testcase.
From-SVN: r266999
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/sem_ch3.adb | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 34c3a2f..76c6e76 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2018-12-11 Ed Schonberg <schonberg@adacore.com> + + * sem_ch3.adb (Build_Itype_Reference): Handle properly an itype + reference created for a function that is a compilation unit, for + example if the function builds in place an object of a limited + type. + 2018-12-11 Dmitriy Anisimkov <anisimko@adacore.com> * libgnat/g-socket.ads, libgnat/g-socket.adb: Fix duration diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index d99370a..5195f8a 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -10368,12 +10368,13 @@ package body Sem_Ch3 is -- If Nod is a library unit entity, then Insert_After won't work, -- because Nod is not a member of any list. Therefore, we use -- Add_Global_Declaration in this case. This can happen if we have a - -- build-in-place library function. + -- build-in-place library function, child unit or not. if (Nkind (Nod) in N_Entity and then Is_Compilation_Unit (Nod)) or else - (Nkind (Nod) = N_Defining_Program_Unit_Name - and then Is_Compilation_Unit (Defining_Identifier (Nod))) + (Nkind_In (Nod, + N_Defining_Program_Unit_Name, N_Subprogram_Declaration) + and then Is_Compilation_Unit (Defining_Entity (Nod))) then Add_Global_Declaration (IR); else |