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] |
For a function with a limited class-wide result, the attempt to execute a return statement with an expression given by an aggregate of an extended type resulted in a Constraint_Error. This occurred because the expansion of the aggregate results in individual assignments of the extended components to the class-wide return object, and gigi generates the raise of an exception with a discriminant-check failure (treating it like violation of a discriminant of the target object). This is fixed by ensuring that a conversion to the specific type is done for such component assignments when the target object is class-wide. Also, the case of a simple return of an aggregate in a class-wide function is now handled by creating a return object of the specific type rather than the class-wide type, avoiding the potentially expensive conversions in that case. See gnat.dg/bip_aggregate_bug.adb 2008-08-04 Gary Dismukes <dismukes@adacore.com> * exp_aggr.adb (Build_Record_Aggr_Code): Perform a conversion of the target to the type of the aggregate in the case where the target object is class-wide. * exp_ch5.adb (Expand_Simple_Function_Return): When the function's result type is class-wide and inherently limited, and the expression has a specific type, create a return object of the specific type, for more efficient handling of returns of build-in-place aggregates (avoids conversions of the class-wide return object to the specific type on component assignments). * sem_ch6.adb (Check_Return_Subtype_Indication): Suppress the error about a type mismatch for a class-wide function with a return object having a specific type when the object declaration doesn't come from source. Such an object can result from the expansion of a simple return.
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] |