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
+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
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
+2019-07-01 Ed Schonberg <schonberg@adacore.com>
+
+ * gnat.dg/weak3.adb, gnat.dg/weak3.ads: New testcase.
+
2019-07-01 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/prot7.adb, gnat.dg/prot7.ads: New testcase.
--- /dev/null
+-- { dg-do compile }
+
+package body Weak3 is
+
+ type T is new Integer;
+ pragma Weak_External (T); -- { dg-error "pragma applies to objects and subprograms" }
+ X : T;
+
+ procedure Foo is null;
+
+end Weak3;
--- /dev/null
+package Weak3 is
+ procedure Foo;
+end Weak3;