ada: Fix expansion of type aspects with handling of aspects The new handling of aspects stores the aspect expression as the Expression_Copy of the aspect and not as the Entity of the aspect identified. This has been changed for most of the aspects, but not for Type_Invariant and Default_Initial_Condition, which have custom expansion. Apparently this change only affects GNATprove and not GNAT. gcc/ada/ * exp_util.adb (Add_Own_DIC, Add_Own_Invariants): Store the aspect expression in Expression_Copy.
Before yesterdaygcc/ada history
ada: Cleanup more "not Present" We had a GNATcheck rule that suggests replacing "not Present (...)" with "No (...)", but it only detected calls with a parameter of type Node_Id. Now this rules also detects parameters of type Elist_Id. gcc/ada/ * sem_ch3.adb, sem_ch4.adb, sem_eval.adb: Fix newly detected violations.
ada: Avoid extra conversion in expansion of packed array assignments Expansion of assignments to packed array objects with string literals on the right-hand side, created an unnecessary conversion, i.e.: ... := component_type (declare temp : component_type := "string_literal"; begin temp) Now the expansion omits the outer type conversion. Cleanup; behavior is unaffected. gcc/ada/ * exp_pakd.adb (Expand_Bit_Packed_Element_Set): Simplify handling of assignments with string literals.
ada: Remove duplicated code for expansion of packed array assignments Expansion of assignments to packed array objects has two cases and had duplicated code for both these cases. gcc/ada/ * exp_pakd.adb (Expand_Bit_Packed_Element_Set): Remove code from the ELSE branch, because it was is identical to code before the IF statements itself.
ada: Simplify expansion of packed array assignments When expanding assignment to a packed array object, e.g. a formal parameter with mode OUT that might have unconstrained type, we took the component type and component size from the constrained actual subtype. It is simpler to take these properties from the nominal type of the assigned object. Semantics is unaffected, because constraining the array doesn't change the type or size of the array components. gcc/ada/ * exp_pakd.adb (Expand_Bit_Packed_Element_Set): Change Ctyp and Csiz from variables to constants and compute them using the nominal type of the assigned array object.
ada: Fix extra whitespace after END keywords Style cleanup. gcc/ada/ * exp_pakd.adb, libgnarl/s-osinte__android.ads, libgnarl/s-osinte__linux.ads, libgnarl/s-osinte__qnx.ads, libgnarl/s-osinte__rtems.ads, libgnat/s-gearop.adb, libgnat/s-poosiz.adb, sem_util.adb: Fix style.
ada: Explicitly analyze and expand null array aggregates Null array aggregates have present but empty lists of expressions and component associations. This confuses the previous code for ordinary array aggregates, which assumes that if a list of either expressions or component associations is present, then it is non-empty. This patch adds explicit handling for null array aggregates to avoid assertion failures in code for ordinary array aggregates. gcc/ada/ * exp_aggr.adb (Build_Array_Aggr_Code): Don't build aggregate code for null array aggregates. * sem_aggr.adb (Resolve_Array_Aggregate): Don't examine formatting of a null array aggregate.
ada: Remove redundant protection against empty list Calls to First on No_List intentionally return Empty, so explicit guards against No_List are unnecessary. Code cleanup; semantics is unaffected. gcc/ada/ * sem_type.adb (Interface_Present_In_Ancestor): Remove guard against no list of interfaces; fix style in comments (trailing dots).
ada: Add guard before querying the type for its interfaces Fix crash on illegal code, when routine Iface_Present_In_Ancestor is called on the predefined String type and attempts to examine the list of interfaces. gcc/ada/ * sem_type.adb (Iface_Present_In_Ancestor): Only look at the list of interfaces for types that allow it. The guard is a high-level equivalent of the entity kinds listed in the preconditon of the Interfaces query.
ada: Extend precondition of Interfaces.C.String.Value with Length The existing precondition guarded against exception Dereference_Error, but not against Constraint_Error. The RM rule B.3.1(36/3) only mentions Constraint_Error for the Value function which returns char_array, but the one which returns String has the same restriction, because it is equivalent to calling the variant which returns char_array and then converted. gcc/ada/ * libgnat/i-cstrin.ads (Value): Extend preconditions; adapt comment for the package.
ada: Add guard for detection of class-wide precondition subprograms When skipping check on subprograms built for class-wide preconditions we must deal with the current scope not being a subprogram, e.g. it could be a declare-block. gcc/ada/ * sem_res.adb (Resolve_Actuals): Add guard for the call to Class_Preconditions_Subprogram.
ada: Leave detection of missing return in functions to GNATprove GNAT has a heuristic to warn about missing return statements in functions. This warning was escalated to errors when operating in GNATprove mode and SPARK_Mode was On. However, this heuristic was imprecise and caused spurious errors. Also, it was applied after the Push_Scope/End_Scope, so for functions acting as compilation units it was using the wrong SPARK_Mode. It is better to simply leave this detection to GNATprove. gcc/ada/ * sem_ch6.adb (Check_Statement_Sequence): Only warn about missing return statements and let GNATprove emit a check when needed.
ada: Allow calls to Number_Formals when no formals are present It is much simpler and safer for the routine Number_Formals to accept subprogram entities that have no formals. gcc/ada/ * einfo-utils.adb (Number_Formals): Change types in body. * einfo-utils.ads (Number_Formals): Change type in spec. * einfo.ads (Number_Formals): Change type in comment. * sem_ch13.adb (Is_Property_Function): Fix style in a caller of Number_Formals that was likely to crash because of missing guards.
ada: Improve defense against illegal code in check for infinite loops Fix crash occurring when attribute System'To_Address is used without a WITH clause for package System. gcc/ada/ * sem_warn.adb (Check_Infinite_Loop_Warning): Don't look at the type of actual parameter when it has no type at all, e.g. because the entire subprogram call is illegal.