diff options
author | Ed Schonberg <schonberg@adacore.com> | 2019-07-01 13:37:11 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-01 13:37:11 +0000 |
commit | d8f8b16648d012d68ccb148a808c9a404960ea20 (patch) | |
tree | 94968be63058385a8167d7cccdbab83574357188 /gcc/ada | |
parent | 9d8aaa4e00958418c01a4aee5a08261108eaf997 (diff) | |
download | gcc-d8f8b16648d012d68ccb148a808c9a404960ea20.zip gcc-d8f8b16648d012d68ccb148a808c9a404960ea20.tar.gz gcc-d8f8b16648d012d68ccb148a808c9a404960ea20.tar.bz2 |
[Ada] Crash on improper pragma Weak_External
This patch adds a guard on the use of pragma Weak_External. This pragma
affects link-time addresses of entities, and does not apply to types.
Previous to this patch the compiler would abort on a misuse of the
pragma.
2019-07-01 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_prag.adb (Analyze_Pragma, case Weak_External): Pragma only
applies to entities with run-time addresses, not to types.
gcc/testsuite/
* gnat.dg/weak3.adb, gnat.dg/weak3.ads: New testcase.
From-SVN: r272876
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/sem_prag.adb | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 65ca1e6..f2e8f39 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-07-01 Ed Schonberg <schonberg@adacore.com> + + * sem_prag.adb (Analyze_Pragma, case Weak_External): Pragma only + applies to entities with run-time addresses, not to types. + 2019-07-01 Piotr Trojanek <trojanek@adacore.com> * einfo.adb, sem_ch7.adb, sem_prag.adb, sem_util.adb: Update diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index b6d259f..ca3603c 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -25608,6 +25608,12 @@ package body Sem_Prag is Ent := Underlying_Type (Ent); end if; + -- The pragma applies to entities with addresses. + + if Is_Type (Ent) then + Error_Pragma ("pragma applies to objects and subprograms"); + end if; + -- The only processing required is to link this item on to the -- list of rep items for the given entity. This is accomplished -- by the call to Rep_Item_Too_Late (when no error is detected |