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 X-Received: by 2002:a5e:8c1a:: with SMTP id n26mr4091845ioj.16.1552693838253; Fri, 15 Mar 2019 16:50:38 -0700 (PDT) X-Received: by 2002:aca:efd6:: with SMTP id n205mr3044827oih.84.1552693837906; Fri, 15 Mar 2019 16:50:37 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!u18no137004ita.0!news-out.google.com!y88ni198ita.0!nntp.google.com!u18no137001ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 15 Mar 2019 16:50:37 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.77.182.20; posting-account=W2gdXQoAAADxIuhBWhPFjUps3wUp4RhQ NNTP-Posting-Host: 76.77.182.20 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: suppress "unspecified order" error in gnat? From: Stephen Leake Injection-Date: Fri, 15 Mar 2019 23:50:38 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 3316 X-Received-Body-CRC: 2504560506 Xref: reader01.eternal-september.org comp.lang.ada:55876 Date: 2019-03-15T16:50:37-07:00 List-Id: I'd like to compile the following: New_Nonterm : constant Valid_Node_Index := Tree.Add_Nonterm ((+nonterminal_ID, 0), (1 => Tree.Add_Identifier (+IDENTIFIER_ID, New_Identifier), 2 => Tree.Add_Terminal (+COLON_ID), 3 => RHS_Alt_Node, 4 => Tree.Add_Nonterm ((+semicolon_opt_ID, 0), (1 => Tree.Add_Terminal (+SEMICOLON_ID))))); but GNAT complains: wisitoken_grammar_runtime.adb:715:19: value of actual may be affected by call in other actual because they are evaluated in unspecified order Here "Tree" is a syntax tree, and the various Tree.Add_* functions insert items in the tree and return a tree node id. In this case, it does not matter what order the aggregate elements are evaluated in. Normally I applaud this error, but I'd like to turn it off in this case. Applying 'pragma Warnings' doesn't work, because this is not a warning; it's an error. Surprisingly, I can write a subprogram to work around this; the above becomes New_Nonterm : constant Valid_Node_Index := Add_Nonterm ((+nonterminal_ID, 0), Child_1 => Tree.Add_Identifier (+IDENTIFIER_ID, New_Identifier), Child_2 => Tree.Add_Terminal (+COLON_ID), Child_3 => RHS_Alt_Node, Child_4 => Tree.Add_Nonterm ((+semicolon_opt_ID, 0), (1 => Tree.Add_Terminal (+SEMICOLON_ID)))); Note that Child_1 .. Child_4 are also evaluated in an arbitrary order, according to the ARM (6.4 10). Maybe GNAT imposes an order here, but not in an aggregate? But I have similar statements that are harder to work around: Tree.Set_Children (Comp_Unit_List_Tail, (1 => Tree.Add_Nonterm ((+compilation_unit_list_ID, 0), (1 => Tree.Add_Nonterm ((+compilation_unit_ID, 1), (1 => New_Nonterm)))))); Here I need to declare some local vars to enforce an order. Ugly. This aggregate nicely reflects the actual tree structure; morphing it to use local vars destroys that.