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] Various fixes in the handling and generation of run-time checks

Tested on i686-linux, committed on trunk.

Various fixes in the handling and generation of run-time checks:

Range checks are not applied to a discriminant that appears by itself in
range constraint: the check will be applied when an object of the type is
created, within the corresponding initialization procedure. This rule was
not being applied to synchronized types, leading to out-of-scope reference
to a discriminant used to constrain a task entry family.

gnat.dg/discr_range_check.adb should compile quietly.

The code that inserts alignment checks on the expression in address
clauses used to copy the expression into the checking code, resulting
in unwanted side effects if e.g. the expression contains function calls.
This patch removes the side effects from the expression before applying
the alignment check.

gnat.dg/align_check.adb must compile and execute quietly.

This patch also corrects some cases where dynamic range checks were still
generated even though index or range checks were suppressed for some
relevant entities. In particular there were cases of range checks
not suppressed for subscript checking when index checks had been
suppressed for the array object or its type.

gnat.dg/range_check.adb used to raise Constraint_Error, it now
executes quietly.

Note: theoretically the above test program is erroneous and could
blow up. In practice it is unlikely to do so.

This set of patches also provide a number of enhancements in front end
handling of address clauses as follows:

 - Removal of many cases of unneeded dynamic alignment checks
 - More warnings at compile time of possible wrong alignments
 - Warnings on overlaying a smaller variable with a larger one
 - New check Alignment_Check to suppress these warnings

Finally, this patch improves validity checking in two ways. First it removes
some silly checks on the result of membership tests. Second it ensures that
operands in ranges are validity checked (including the cases of loop
bounds, array bounds, and subtype bounds). These are now included as
operands (they are not technically operands, but informally .. acts
as an operator for this kind of purpose). A related clean up in this
patch is to introduce a new subtype in N_Membership_Test
and use it where appropriate.
2006-10-31  Robert Dewar  <>
	    Ed Schonberg  <>

	* treepr.adb: Use new subtype N_Membership_Test

        *, checks.adb: Add definition for Validity_Check
        (Range_Or_Validity_Checks_Suppressed): New function
        (Ensure_Valid): Test Validity_Check suppressed
        (Insert_Valid_Check): Test Validity_Check suppressed
        (Insert_Valid_Check): Preserve Do_Range_Check flag
	(Validity_Check_Range): New procedure
	(Expr_Known_Valid): Result of membership test is always valid
	(Selected_Range_Checks): Range checks cannot be applied to discriminants
	by themselves. Disabling those checks must also be done for task types,
	where discriminants may be used for the bounds of entry families.
	(Apply_Address_Clause_Check): Remove side-effects if address expression
	is non-static and is not the name of a declared constant.
	(Null_Exclusion_Static_Checks): Extend to handle Function_Specification.
	Code cleanup and new error messages.
	(Enable_Range_Check): Test for some cases of suppressed checks
	(Generate_Index_Checks): Suppress index checks if index checks are
	suppressed for array object or array type.
	(Apply_Selected_Length_Checks): Give warning for compile-time detected
	length check failure, even if checks are off.
	(Ensure_Valid): Do not generate a check on an indexed component whose
	prefix is a packed boolean array.
	* checks.adb: (Alignment_Checks_Suppressed): New function
	(Apply_Address_Clause_Check): New procedure, this is a completely
	rewritten replacement for Apply_Alignment_Check
	(Get_E_Length/Get_E_First_Or_Last): Add missing barrier to ensure that
	we request a discriminal value only in case of discriminants.
	(Apply_Discriminant_Check): For Ada_05, only call Get_Actual_Subtype for
	assignments where the target subtype is unconstrained and the target
	object is a parameter or dereference (other aliased cases are known
	to be unconstrained).

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]