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 implements a new configuration pragma Short_Circuit_And_Or that treats any AND on Standard.Boolean operands as AND THEN, and any OR on Standard.Boolean operands as OR ELSE. This can be useful in the context of certification tools requiring short circuited logical operators. The following program: pragma Short_Circuit_And_Or; function scandor (a, b : integer) return integer is begin if a > 0 and b > 0 then return 23; elsif a > 23 or b > 23 then return 24; else return 43; end if; end scandor; compiled with -gnatG yields: Source recreated from tree for scandor (body) pragma short_circuit_and_or; function scandor (a : integer; b : integer) return integer is begin if a > 0 and then b > 0 then return 23; elsif a > 23 or else b > 23 then return 24; else return 43; end if; end scandor; Tested on x86_64-pc-linux-gnu, committed on trunk 2009-11-30 Robert Dewar <dewar@adacore.com> * exp_ch4.adb (Expand_N_Op_And): Implement pragma Short_Circuit_And_Or (Expand_N_Op_Or): Implement pragma Short_Circuit_And_Or * opt.ads (Short_Circuit_And_Or): New flag * par-prag.adb: Add dummy entry for pragma Short_Circuit_And_Or * sem_prag.adb: Implement pragma Short_Circuit_And_Or * snames.ads-tmpl: Add entries for pragma Short_Circuit_And_Or
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] |