This is the mail archive of the 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]

[Ada] Checks fail on right operand of "and" and "or" with Short_Circuit_And_Or

When the pragma Short_Circuit_And_Or is used, no part of the right operand
of an "and" or "or" operator should be executed if the left operand would
short-circuit the evaluation of the corresponding "and then" or "or else".
However, run-time checks associated with such operands were being evaluated
unconditionally, due to being before to the condition prior to the rewriting
as short-circuit forms during expansion. This is corrected by doing the
rewrite during analysis of the logical operators rather than waiting until

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-10-14  Gary Dismukes  <>

	* exp_ch4.adb (Expand_N_Op_And): Remove Short_Circuit_And_Or
	expansion code (moved to sem_res) (Expand_N_Op_Or): Remove
	Short_Circuit_And_Or expansion code (moved to sem_res).
	* sem_res.adb (Resolve_Logical_Op): Add code to rewrite Boolean
	"and" and "or" operators as short-circuit "and then" and "or
	else", when pragma Short_Circuit_And_Or is active.

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]