[multiple changes]
2012-10-03 Ed Schonberg <schonberg@adacore.com> * sem_ch6.adb (New_Overloaded_Entity): call Append_Inherited_Subprogram when appropriate. * sem_dim.adb (Analyze_Dimension_Call): Do not perform dimensional analysis if call has previous semantic error. * sem_util.ads, sem_util.adb (Append_Inherited_Subprogram): new subprogram to handle properly the visibility of inherited operations that are primitives of a type extension, when the parent type and operations are declared in the same visible part. 2012-10-03 Robert Dewar <dewar@adacore.com> * checks.adb (Minimize_Eliminate_Overflow_Checks): Properly handle case of top level expression within type conversion * gnat1drv.adb (Adjust_Global_Switches): Set SUPPRESSED as default for overflow checking for -gnatg mode (includes run-time). * sem_res.adb (Resolve_Type_Conversion): Avoid bogus warnings about redundant conversions from MINIMIZED/EXTENDED mode checking From-SVN: r192029
This commit is contained in:
parent
3bfb3c03da
commit
2352eadb81
@ -1,3 +1,23 @@
|
||||
2012-10-03 Ed Schonberg <schonberg@adacore.com>
|
||||
|
||||
* sem_ch6.adb (New_Overloaded_Entity): call
|
||||
Append_Inherited_Subprogram when appropriate.
|
||||
* sem_dim.adb (Analyze_Dimension_Call): Do not perform dimensional
|
||||
analysis if call has previous semantic error.
|
||||
* sem_util.ads, sem_util.adb (Append_Inherited_Subprogram):
|
||||
new subprogram to handle properly the visibility of inherited
|
||||
operations that are primitives of a type extension, when the
|
||||
parent type and operations are declared in the same visible part.
|
||||
|
||||
2012-10-03 Robert Dewar <dewar@adacore.com>
|
||||
|
||||
* checks.adb (Minimize_Eliminate_Overflow_Checks): Properly
|
||||
handle case of top level expression within type conversion
|
||||
* gnat1drv.adb (Adjust_Global_Switches): Set SUPPRESSED as
|
||||
default for overflow checking for -gnatg mode (includes run-time).
|
||||
* sem_res.adb (Resolve_Type_Conversion): Avoid bogus warnings
|
||||
about redundant conversions from MINIMIZED/EXTENDED mode checking
|
||||
|
||||
2012-10-03 Javier Miranda <miranda@adacore.com>
|
||||
|
||||
* exp_ch4.adb (Expand_N_Allocator_Expression): Minor code
|
||||
|
@ -7404,6 +7404,16 @@ package body Checks is
|
||||
|
||||
elsif Top_Level
|
||||
and then not (Bignum_Operands or Long_Long_Integer_Operands)
|
||||
|
||||
-- One further refinement. If we are at the top level, but our parent
|
||||
-- is a type conversion, then go into bignum or long long integer node
|
||||
-- since the result will be converted to that type directly without
|
||||
-- going through the result type, and we may avoid an overflow. This
|
||||
-- is the case for example of Long_Long_Integer (A ** 4), where A is
|
||||
-- of type Integer, and the result A ** 4 fits in Long_Long_Integer
|
||||
-- but does not fit in Integer.
|
||||
|
||||
and then Nkind (Parent (N)) /= N_Type_Conversion
|
||||
then
|
||||
-- Here we will keep the original types, but we do need an overflow
|
||||
-- check, so we will set Do_Overflow_Check to True (actually it is
|
||||
@ -7561,12 +7571,6 @@ package body Checks is
|
||||
|
||||
if Nkind (N) = N_Op_Expon and then Etype (Right_Opnd (N)) = LLIB then
|
||||
Convert_To_And_Rewrite (Standard_Natural, Right_Opnd (N));
|
||||
|
||||
-- Now Long_Long_Integer_Operands may have to be reset if that was
|
||||
-- the only long long integer operand, i.e. we now have long long
|
||||
-- integer operands only if the left operand is long long integer.
|
||||
|
||||
Long_Long_Integer_Operands := Etype (Left_Opnd (N)) = LLIB;
|
||||
end if;
|
||||
|
||||
-- Here we will do the operation in Long_Long_Integer. We do this even
|
||||
|
@ -334,6 +334,12 @@ procedure Gnat1drv is
|
||||
if Opt.Suppress_Options.Overflow_Checks_General /= Not_Set then
|
||||
null;
|
||||
|
||||
-- By default suppress overflow checks in -gnatg mode
|
||||
|
||||
elsif GNAT_Mode then
|
||||
Suppress_Options.Overflow_Checks_General := Suppressed;
|
||||
Suppress_Options.Overflow_Checks_Assertions := Suppressed;
|
||||
|
||||
-- If we have backend divide and overflow checks, then by default
|
||||
-- overflow checks are minimized, which is a reasonable setting.
|
||||
|
||||
|
@ -8063,7 +8063,12 @@ package body Sem_Ch6 is
|
||||
|
||||
Set_Homonym (S, E);
|
||||
|
||||
Append_Entity (S, Current_Scope);
|
||||
if Is_Inherited_Operation (S) then
|
||||
Append_Inherited_Subprogram (S);
|
||||
else
|
||||
Append_Entity (S, Current_Scope);
|
||||
end if;
|
||||
|
||||
Set_Public_Status (S);
|
||||
|
||||
if Debug_Flag_E then
|
||||
|
@ -1508,10 +1508,12 @@ package body Sem_Dim is
|
||||
|
||||
begin
|
||||
-- Aspect is an Ada 2012 feature. Note that there is no need to check
|
||||
-- dimensions for calls that don't come from source.
|
||||
-- dimensions for calls that don't come from source, or those that may
|
||||
-- have semantic errors.
|
||||
|
||||
if Ada_Version < Ada_2012
|
||||
or else not Comes_From_Source (N)
|
||||
or else Error_Posted (N)
|
||||
then
|
||||
return;
|
||||
end if;
|
||||
|
@ -9624,6 +9624,13 @@ package body Sem_Res is
|
||||
then
|
||||
null;
|
||||
|
||||
-- Never warn on conversion to Long_Long_Integer'Base since
|
||||
-- that is most likely an artifact of the extended overflow
|
||||
-- checking and comes from complex expanded code.
|
||||
|
||||
elsif Orig_T = Base_Type (Standard_Long_Long_Integer) then
|
||||
null;
|
||||
|
||||
-- Here we give the redundant conversion warning. If it is an
|
||||
-- entity, give the name of the entity in the message. If not,
|
||||
-- just mention the expression.
|
||||
|
@ -279,6 +279,63 @@ package body Sem_Util is
|
||||
return Alignment (E) * System_Storage_Unit;
|
||||
end Alignment_In_Bits;
|
||||
|
||||
---------------------------------
|
||||
-- Append_Inherited_Subprogram --
|
||||
---------------------------------
|
||||
|
||||
procedure Append_Inherited_Subprogram (S : Entity_Id) is
|
||||
Par : constant Entity_Id := Alias (S);
|
||||
-- The parent subprogram
|
||||
|
||||
Scop : constant Entity_Id := Scope (Par);
|
||||
-- The scope of definition of the parent subprogram
|
||||
|
||||
Typ : constant Entity_Id := Defining_Entity (Parent (S));
|
||||
-- The derived type of which S is a primitive operation
|
||||
|
||||
Decl : Node_Id;
|
||||
Next_E : Entity_Id;
|
||||
|
||||
begin
|
||||
if Ekind (Current_Scope) = E_Package
|
||||
and then In_Private_Part (Current_Scope)
|
||||
and then Has_Private_Declaration (Typ)
|
||||
and then Is_Tagged_Type (Typ)
|
||||
and then Scop = Current_Scope
|
||||
then
|
||||
-- The inherited operation is available at the earliest place after
|
||||
-- the derived type declaration ( RM 7.3.1 (6/1)). This is only
|
||||
-- relevant for type extensions. If the parent operation appears
|
||||
-- after the type extension, the operation is not visible.
|
||||
|
||||
Decl := First
|
||||
(Visible_Declarations
|
||||
(Specification (Unit_Declaration_Node (Current_Scope))));
|
||||
while Present (Decl) loop
|
||||
if Nkind (Decl) = N_Private_Extension_Declaration
|
||||
and then Defining_Entity (Decl) = Typ
|
||||
then
|
||||
if Sloc (Decl) > Sloc (Par) then
|
||||
Next_E := Next_Entity (Par);
|
||||
Set_Next_Entity (Par, S);
|
||||
Set_Next_Entity (S, Next_E);
|
||||
return;
|
||||
|
||||
else
|
||||
exit;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
Next (Decl);
|
||||
end loop;
|
||||
end if;
|
||||
|
||||
-- If partial view is not a type extension, or it appears before the
|
||||
-- subprogram declaration, insert normally at end of entity list.
|
||||
|
||||
Append_Entity (S, Current_Scope);
|
||||
end Append_Inherited_Subprogram;
|
||||
|
||||
-----------------------------------------
|
||||
-- Apply_Compile_Time_Constraint_Error --
|
||||
-----------------------------------------
|
||||
|
@ -63,6 +63,12 @@ package Sem_Util is
|
||||
-- Otherwise Uint_0 is returned, indicating that the alignment of the
|
||||
-- entity is not yet known to the compiler.
|
||||
|
||||
procedure Append_Inherited_Subprogram (S : Entity_Id);
|
||||
-- If the parent of the operation is declared in the visible part of
|
||||
-- the current scope, the inherited operation is visible even though the
|
||||
-- derived type that inherits the operation may be completed in the private
|
||||
-- part of the current package.
|
||||
|
||||
procedure Apply_Compile_Time_Constraint_Error
|
||||
(N : Node_Id;
|
||||
Msg : String;
|
||||
|
Loading…
Reference in New Issue
Block a user