[Ada] Handling of pragma Predicate

Programming / Compilers / GCC - pmderodat [138bc75d-0d04-0410-961f-82ee72b054a4] - 11 January 2018 08:51 EST

This patch fixes an omission in the processing of pragma Predicate, which should have the same semantics as the corresponding aspect, which is more commonly used.

Executing gnatmake -q -gnata predicate predicate

must yield:

Even1 violated Even2 violated


with Text_IO; use Text_IO; procedure Predicate is begin begin declare subtype Even1 is Integer; pragma Predicate (Even1, Even1 mod 2 = 0); X1 : constant Even1 := 1; -- This should fail first begin null; end; exception when Others => Put_Line ("Even1 violated"); end;

begin declare subtype Even2 is Integer with Predicate => Even2 mod 2 = 0; X2 : constant Even2 := 1; -- This should fail later, if reached begin null; end; exception when Others => Put_Line ("Even2 violated"); end; end;

2018-01-11 Ed Schonberg

gcc/ada/

- sem_prag.adb (Analyze_Pragma, case Predicate): Indicate that the type has a delayed aspect which must be processed at the point the type is frozen. This mimics what is done when the predicate is provided by a source aspect.

199ce685f24 [Ada] Handling of pragma Predicate
gcc/ada/ChangeLog | 7 +++++++
gcc/ada/sem_prag.adb | 7 +++++++
2 files changed, 14 insertions(+)

Upstream: gcc.gnu.org


  • Share