* [Ada] Missing predicate check with explicit policy pragma
@ 2016-10-12 14:00 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2016-10-12 14:00 UTC (permalink / raw)
To: gcc-patches; +Cc: Ed Schonberg
[-- Attachment #1: Type: text/plain, Size: 1147 bytes --]
This patch fixes an omission in the generation of predicate checks, when there
is a configuration pragma that sets Assertion_Policy to Ignore and a subsequent
configuration pragma that enables predicate checking.
Executing:
gnatmake -q main
main
must yield
raised SYSTEM.ASSERTIONS.ASSERT_FAILURE :
Dynamic_Predicate failed at main.adb:5
---
pragma Assertion_Policy (Ignore);
pragma Assertion_Policy
(Static_Predicate => Check,
Dynamic_Predicate => Check,
Pre => Check, Pre'Class => Check);
---
with Pred;
procedure Main is
begin
Pred.Foo ("");
end;
---
package Pred is
subtype Not_Empty_String is String
with Dynamic_Predicate => Not_Empty_String /= "";
procedure Foo (S : Not_Empty_String);
end;
---
package body Pred is
procedure Foo (S : Not_Empty_String) is begin null; end;
end;
Tested on x86_64-pc-linux-gnu, committed on trunk
2016-10-12 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb (Analyze_Pragma, case Dynamic_Predicate):
Check properly whether there is an explicit assertion policy
for predicate checking, even in the presence of a general Ignore
assertion policy.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1338 bytes --]
Index: sem_prag.adb
===================================================================
--- sem_prag.adb (revision 241048)
+++ sem_prag.adb (working copy)
@@ -19136,15 +19136,17 @@
-- the rep item chain, for processing when the type is frozen.
-- This is accomplished by a call to Rep_Item_Too_Late. We also
-- mark the type as having predicates.
- -- If the current policy is Ignore mark the subtype accordingly.
- -- In the case of predicates we consider them enabled unless an
- -- Ignore is specified, to preserve existing warnings.
+ -- If the current policy for predicate checking is Ignore mark the
+ -- subtype accordingly. In the case of predicates we consider them
+ -- enabled unless Ignore is specified (either directly or with a
+ -- general Assertion_Policy pragma) to preserve existing warnings.
+
Set_Has_Predicates (Typ);
Set_Predicates_Ignored (Typ,
Present (Check_Policy_List)
and then
- Policy_In_Effect (Name_Assertion_Policy) = Name_Ignore);
+ Policy_In_Effect (Name_Dynamic_Predicate) = Name_Ignore);
Discard := Rep_Item_Too_Late (Typ, N, FOnly => True);
end Predicate;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-10-12 14:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12 14:00 [Ada] Missing predicate check with explicit policy pragma Arnaud Charlet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).