This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch fixes an omission in the inheritance of predicate aspects in type derivations. The parent type may be a subtype declaration or a type declaration with a dynamic predicate aspect, and the aspect applies to a first subtype, not to its anonymous parent type. Eecuting: gnatmake -q -gnata test_it test_it must yield: 2 in Even is TRUE 3 in Even is FALSE 2 in New_Even is TRUE 3 in New_Even is FALSE 2 in Newer_Even is TRUE 3 in Newer_Even is FALSE OK --- with Text_IO; use Text_IO; procedure Test_It is type Even is new Integer with Dynamic_Predicate => Even mod 2 = 0; subtype Other_Even is Integer with Dynamic_Predicate => Other_Even mod 2 = 0; type New_Even is new Even; type Newer_Even is new Other_Even; B : Boolean; subtype Small is Integer range -5 .. 5; type New_Small is new Small; begin B := 2 in Even; Put_Line ("2 in Even is " & B'Img); B := 3 in Even; Put_Line ("3 in Even is " & B'Img); B := 2 in New_Even; Put_Line ("2 in New_Even is " & B'Img); B := 3 in New_Even; Put_Line ("3 in New_Even is " & B'Img); B := 2 in Newer_Even; Put_Line ("2 in Newer_Even is " & B'Img); B := 3 in Newer_Even; Put_Line ("3 in Newer_Even is " & B'Img); declare X : New_Even; begin X := 13; exception when Others => Put_Line ("OK"); end; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-01-12 Ed Schonberg <schonberg@adacore.com> * sem_ch3.adb (Build_Derived_Type): For a scalar derived type, inherit predicates if any from the first_subtype of the parent, not from the anonymous parent type. * sem_eval.adb (Is_Static_Subtype): A type that inherits a dynamic predicate is not a static subtype.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |