[Ada] Assertion_Policy (Ignore) ignores invariants
Pierre-Marie de Rodat
derodat@adacore.com
Thu Oct 10 15:30:00 GMT 2019
A pragma Assertion_Policy (Ignore) was ignored with respect to
invariants; invariants are checked even in the presence of this pragma.
This patch fixes that bug.
Running these commands:
gcc -S -fverbose-asm -g ess-main.adb -gnata
grep Invariant ess-main.s
On the following sources:
pragma Assertion_Policy (Ignore);
package Ess is
type T is private;
procedure P (X : T);
private
type T is record
A : Integer;
end record with
Invariant => T.A = 3;
end Ess;
pragma Assertion_Policy (Ignore);
package body Ess is
procedure P (X : T) is
Obj : T;
begin
Obj.A := 4;
end P;
end Ess;
pragma Assertion_Policy (Ignore);
procedure Ess.Main (X : T) is
Obj : T;
begin
Obj.A := 4;
P (Obj);
end Ess.Main;
Should execute silently.
Tested on x86_64-pc-linux-gnu, committed on trunk
2019-10-10 Bob Duff <duff@adacore.com>
gcc/ada/
* einfo.ads, einfo.adb (Invariants_Ignored): New flag on types.
This leaves just one unused flag.
* sem_prag.adb (Invariant): Set the flag if appropriate.
* exp_util.adb (Make_Invariant_Call): Check the flag.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 6521 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20191010/ab9452b9/attachment.bin>
More information about the Gcc-patches
mailing list