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]

[Ada] minor rewordings


Tested on i686-linux, committed on trunk.

This patch does minor rewording of error messages, and also rewords
continuation messages to read better with -gnatj.

The predicate In_Instance is used to disable some semantic checks that
do not apply within an instantiation. The predicate is true if the scope
stack contains an instantiation. However, the predicate must be false
when analyzing the actuals in the instantiation of a generic child unit.
This special case is detected by checking that the current unit is a child
instance, and that it is not currently on the scope stack.
The following compilation must be rejected with the given error message:
--
gcc -c pb-pb_fils-pb_petitfils.ads
--
pb-pb_fils-pb_petitfils.ads:5:23: operator for type "T_Int"
   defined at primitifs.ads:5 is not directly visible
pb-pb_fils-pb_petitfils.ads:5:23: use clause would make operation legal
pb-pb_fils-pb_petitfils.ads:5:23: instantiation abandoned
compilation abandoned due to previous error
--
package Primitifs is
  type T_Int is range -2**31 .. 2**31-1;
  subtype T_Pos is  T_Int range 1 .. T_Int'Last;
end Primitifs;
--
With Primitifs;
Use type Primitifs.T_Int;
package Constants is
  K_1 : constant Primitifs.T_Int := 1;
  K_2 : constant Primitifs.T_Int := 2;
  K_3 : constant Primitifs.T_Int := K_1*K_2;
end Constants;
--
With primitifs;
generic
  Max : Primitifs.T_Pos;
package P_generic is
  type T_generic_Range is new Primitifs.T_Int range 0 .. Max;
  function MyFunction (This : in T_generic_Range) return  T_generic_Range;
end P_generic;
--
package Pa is end Pa;
package Pb is end Pb;
--
With Primitifs;
generic
   package Pa.Pa_fils is
      type T_generic_Range is new Primitifs.T_Int range 0 .. 1;
end Pa.Pa_fils;
--
With Pa.Pa_fils;
package Pb.Pb_fils is new Pa.Pa_fils;
--
With P_generic;
With Constants;
package Pb.Pb_fils.Pb_petitFils is new
    P_generic (Max => Constants.K_1*Constants.K_2); --  ERROR: *

This patch also ensures that Safe_To_Capture_Value always returns
False for variables that are renamings of other variables. This avoids
bogus independent Current_Value tracking for such variables.
See gnat.dg/capture_value.adb

In Ada 2005, the accessibility level of an anonymous access type that is
the return subtype of an extended return statement is the same as the
accessibility level of the anonymous subtype of the enclosing function.

This patch deals with the omission in Kill_Current_values of failing
to walk past a loop, and so missing variables defined in a subprogram
enclosing the loop. This causes trouble in some cases, but is not as
serious as expected, since most current value tracking is disabled
within a loop body (it need not be disabled, but it's a good thing
it was given this bug).
See gnat.dg/kill_value.adb
Without this patch, the inner condition is changed to True, resulting
in this program bombing with an access violation, with the patch in
place the inner test is retained, and the program runs silently.

For the case of a static expression failing a constraint check, the
error message talked about raising constraint error, which was
confusing since this is an error, so execution is not possible.
This patch improves the message to avoid this confusion.
A test program is:

1. procedure Errmsg_Example is
2.    type Byte is mod 256;
3.    B : Byte;
4.    type Temp is range 20 .. 30;
5.    T : Temp;
6. begin
7.    B := 500;                    -- Illegal
           |
   >>> value not in range of type "Byte" defined at line 2
   >>> static expression fails Constraint_Check

 8.    T := 1_000_000;              -- Illegal
           |
   >>> value not in range of type "Temp" defined at line 4
   >>> static expression fails Constraint_Check

 9.    T := 10;                     -- Legal, will raise C_E at run time
            |
   >>> warning: value not in range of type "Temp" defined at line 4
   >>> warning: "Constraint_Error" will be raised at run time

10. end Errmsg_Example;

2006-10-31  Robert Dewar  <dewar@adacore.com>
	    Hristian Kirtchev  <kirtchev@adacore.com>
	    Ed Schonberg  <schonberg@adacore.com>
        
        * sem_util.ads, sem_util.adb (Enter_Name): Exclude -gnatwh warning
	messages for entities in packages which are not used.
	(Collect_Synchronized_Interfaces): New procedure.
	(Overrides_Synchronized_Primitive): New function.
	(Denotes_Discriminant): Extend predicate to apply to task types.
	Add missing continuation marks in error msgs
	(Unqualify): New function for removing zero or more levels of
	qualification from an expression. There are numerous places where this
	ought to be used, but we currently only deal properly with zero or one
	level.
	(In_Instance); The analysis of the actuals in the instantiation of a
	child unit is not within an instantiation, even though the parent
	instance is on the scope stack.
	(Safe_To_Capture_Value): Exclude the case of variables that are
	renamings.
	(Check_Obsolescent): Removed
	(Is_Aliased_View): A reference to an enclosing instance in an aggregate
	is an aliased view, even when rewritten as a reference to the target
	object in an assignment.
	(Get_Subprogram_Entity): New function
	(Known_To_Be_Assigned): New function
	(Type_Access_Level): Compute properly the access level of a return
	subtype that is an anonymous access type.
	(Explain_Limited_Type): Correct use of "\" for continuation messages.
	(Is_Transfer): The new extended_return_statement causes a transfer of
	control.
	(Has_Preelaborable_Initialization): New function
	(Has_Null_Exclusion): New function. Given a node N, determine whether it
	has a null exclusion depending on its Nkind.
	Change Is_Lvalue to May_Be_Lvalue
	(May_Be_Lvalue): Extensive additional code to deal with subprogram
	arguments (IN parameters are not Lvalues, IN OUT parameters are).
	(Safe_To_Capture_Value): Extend functionality so it can be used for
	the current value condition case.
	(Has_Compatible_Alignment): New function
	(Is_Dependent_Component_Of_Mutable_Object): Revise the tests for mutable
	objects to handle the Ada 2005 case, where aliasedness no longer implies
	that the object is constrained. In particular, for dereferenced names,
	the designated object must be assumed to be unconstrained.
	(Kill_Current_Values): Properly deal with the case where we encounter
	a loop in the scope chain.
	(Safe_To_Capture_Value): Do not let a loop stop us from capturing
	a value.
	(Compile_Time_Constraint_Error): Improve error message in error case

	* exp_ch13.adb (Expand_N_Freeze_Entity): Remove the freezing node
	associated with entities of abstract interface primitives.
	Call Apply_Address_Clause_Check instead of Apply_Alignment_Check

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]