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 corrects the implementation of static predicates in the context of case expressions and/or statements. The maching of individual case alternatives is now done against the sets of legal values defined by the static predicate. ------------ -- Source -- ------------ -- static_predicates.adb procedure Static_Predicates is type Typ is (A, B, C, D, E, F, G, H, I, J, K, L, M, N); subtype Subtyp is Typ with Static_Predicate => Subtyp in D .. F | H | J .. L; -- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 -- +-------+ +-+ +-------+ -- A B C |D E F| G |H| I |J K L| M N -- +-------+ +-+ +-------+ Obj : Subtyp; begin case Obj is when A .. B => null; -- A .. B illegal end case; case Obj is when B .. D => null; -- B .. C illegal end case; case Obj is -- missing F, H, J .. L when D .. E => null; end case; case Obj is when E .. G => null; -- G illegal end case; case Obj is when F .. H => null; -- G illegal end case; case Obj is -- missing D .. F when G .. H => null; -- G illegal end case; case Obj is -- missing D .. F when H .. I => null; -- I illegal end case; case Obj is -- missing D .. F, H when I .. M => null; -- I illegal end case; case Obj is -- ok when D .. F => null; when H => null; when J .. L => null; end case; case Obj is when D .. E => null; when G .. N => null; -- G illegal when others => null; end case; case Obj is when D => null; when D .. F => null; -- D duplicated when H => null; when J .. L => null; end case; case Obj is when D .. F => null; when H => null; when J .. L => null; when J => null; -- J duplicated end case; end Static_Predicates; ---------------------------- -- Compilation and output -- ---------------------------- gcc -c -gnat12 static_predicates.adb static_predicates.adb:16:14: static predicate on "Subtyp" excludes range "A" .. "B" static_predicates.adb:19:14: static predicate on "Subtyp" excludes range "B" .. "C" static_predicates.adb:21:04: missing case value: "F" static_predicates.adb:21:04: missing case value: "H" static_predicates.adb:21:04: missing case values: "J" .. "L" static_predicates.adb:25:14: static predicate on "Subtyp" excludes value "G" static_predicates.adb:28:14: static predicate on "Subtyp" excludes value "G" static_predicates.adb:30:04: missing case values: "D" .. "F" static_predicates.adb:31:14: static predicate on "Subtyp" excludes value "G" static_predicates.adb:33:04: missing case values: "D" .. "F" static_predicates.adb:34:14: static predicate on "Subtyp" excludes value "I" static_predicates.adb:36:04: missing case values: "D" .. "F" static_predicates.adb:36:04: missing case value: "H" static_predicates.adb:37:14: static predicate on "Subtyp" excludes value "I" static_predicates.adb:46:14: static predicate on "Subtyp" excludes value "G" static_predicates.adb:50:12: duplication of choice value static_predicates.adb:58:14: duplication of choice value Tested on x86_64-pc-linux-gnu, committed on trunk 2013-04-11 Hristian Kirtchev <kirtchev@adacore.com> * sem_case.adb (Check_Against_Predicate): New routine. (Check_Choices): When the type covered by the list of choices is a static subtype with a static predicate, check all choices agains the predicate. (Issue_Msg): All versions removed. (Missing_Choice): New routines. * sem_ch4.adb: Code and comment reformatting. (Analyze_Case_Expression): Do not check the choices when the case expression is being preanalyzed and the type of the expression is a subtype with a static predicate. (Has_Static_Predicate): New routine. * sem_ch13.adb: Code and comment reformatting. (Build_Range): Always build a range even if the low and hi bounds denote the same value. This is needed by the machinery in Check_Choices. (Build_Static_Predicate): Always build a range even if the low and hi bounds denote the same value. This is needed by the machinery in Check_Choices.
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] |