From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Ada case-statement Date: Thu, 15 Mar 2018 17:24:05 -0500 Organization: JSA Research & Innovation Message-ID: References: <365d65ea-5f4b-4b6a-be9b-1bba146394ab@googlegroups.com> Injection-Date: Thu, 15 Mar 2018 22:24:06 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="23319"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:51013 Date: 2018-03-15T17:24:05-05:00 List-Id: "Stephen Davies" wrote in message news:c398c38e-6567-40e1-b686-7aef94e36fe3@googlegroups.com... > On Wednesday, 14 March 2018 23:16:29 UTC, Randy Brukardt wrote: > >> declare >> Selector : Day_Type renames Calculate_Day; >> subtype Weekend_Subtype is Day_Type range Sat .. Sun; >> -- Or use a static predicate if the range is discontiguous. >> begin >> case Selector is >> when Mon .. Fri => >> ... >> when Sat | Sun => >> ... >> case Weekend_Subtype'(Selector) is -- A type conversion works, >> too. >> when Sat => >> ... >> when Sun => >> ... >> end case; >> end case; >> end; > > Unless this has changed in more recent compilers, the static predicate > when Sat & Sun are not contiguous does not work. Gnatpro 7.0.2 complains > about missing values. Also, attempting to use "when Weekend_Subtype" in > the outer case-statement results in complaints about duplicate values. It should have changed, there are a number of ACATS tests checking precisely this sort of thing. So far as I know, GNAT passes those tests. (And GNATPro 7.0.2 is a looonnnng time ago, based on the ACATS tests I wouldn't expect much of any Ada 2012 features to work in that. I'd guess this would work in all of the ones I've used recently: 7.4.1, 17.1, and 18.1.) Randy.