Commit f91b40db by Geert Bosch

sem_eval.adb (Eval_Concatenation): If left operand is a null string, get bounds from right operand.

	* sem_eval.adb (Eval_Concatenation): If left operand is a null string,
	get bounds from right operand.

	* sem_eval.adb: Minor reformatting

	* exp_util.adb (Make_Literal_Range): use bound of literal rather
	than Index'First, its lower bound may be different from 1.

	* exp_util.adb: Undo earlier change, fixes ACVC regressions C48009B
	and C48009J

	* prj-nmsc.adb Minor reformatting

	* prj-nmsc.adb (Language_Independent_Check): Reset Library flag if
	set and libraries are not supported.

	* sem_ch3.adb (Build_Derived_Private_Type): set Public status of
	private view explicitly, so the back-end can treat as a global
	when appropriate.

From-SVN: r47692
parent ef3d4d6e
2001-12-05 Ed Schonberg <schonber@gnat.com> 2001-12-05 Ed Schonberg <schonber@gnat.com>
* sem_eval.adb (Eval_Concatenation): If left operand is a null string,
get bounds from right operand.
* sem_eval.adb: Minor reformatting
* exp_util.adb (Make_Literal_Range): use bound of literal rather
than Index'First, its lower bound may be different from 1.
* exp_util.adb: Undo earlier change, fixes ACVC regressions C48009B
and C48009J
2001-12-05 Vincent Celier <celier@gnat.com>
* prj-nmsc.adb Minor reformatting
* prj-nmsc.adb (Language_Independent_Check): Reset Library flag if
set and libraries are not supported.
2001-12-05 Ed Schonberg <schonber@gnat.com>
* sem_ch3.adb (Build_Derived_Private_Type): set Public status of
private view explicitly, so the back-end can treat as a global
when appropriate.
2001-12-05 Ed Schonberg <schonber@gnat.com>
* sem_ch12.adb (Instantiate_Package_Body): if instance is a compilation * sem_ch12.adb (Instantiate_Package_Body): if instance is a compilation
unit, always replace instance node with new body, for ASIS use. unit, always replace instance node with new body, for ASIS use.
......
...@@ -125,11 +125,11 @@ package body Exp_Util is ...@@ -125,11 +125,11 @@ package body Exp_Util is
function Make_Literal_Range function Make_Literal_Range
(Loc : Source_Ptr; (Loc : Source_Ptr;
Literal_Typ : Entity_Id; Literal_Typ : Entity_Id)
Index_Typ : Entity_Id)
return Node_Id; return Node_Id;
-- Produce a Range node whose bounds are: -- Produce a Range node whose bounds are:
-- Index_Typ'first .. Index_Typ'First + Length (Literal_Typ) -- Low_Bound (Literal_Type) ..
-- Low_Bound (Literal_Type) + Length (Literal_Typ) - 1
-- this is used for expanding declarations like X : String := "sdfgdfg"; -- this is used for expanding declarations like X : String := "sdfgdfg";
function New_Class_Wide_Subtype function New_Class_Wide_Subtype
...@@ -1137,8 +1137,7 @@ package body Exp_Util is ...@@ -1137,8 +1137,7 @@ package body Exp_Util is
Make_Index_Or_Discriminant_Constraint (Loc, Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => New_List ( Constraints => New_List (
Make_Literal_Range (Loc, Make_Literal_Range (Loc,
Literal_Typ => Exp_Typ, Literal_Typ => Exp_Typ)))));
Index_Typ => Etype (First_Index (Unc_Type)))))));
elsif Is_Constrained (Exp_Typ) elsif Is_Constrained (Exp_Typ)
and then not Is_Class_Wide_Type (Unc_Type) and then not Is_Class_Wide_Type (Unc_Type)
...@@ -2305,28 +2304,27 @@ package body Exp_Util is ...@@ -2305,28 +2304,27 @@ package body Exp_Util is
function Make_Literal_Range function Make_Literal_Range
(Loc : Source_Ptr; (Loc : Source_Ptr;
Literal_Typ : Entity_Id; Literal_Typ : Entity_Id)
Index_Typ : Entity_Id)
return Node_Id return Node_Id
is is
Lo : Node_Id :=
New_Copy_Tree (String_Literal_Low_Bound (Literal_Typ));
begin begin
Set_Analyzed (Lo, False);
return return
Make_Range (Loc, Make_Range (Loc,
Low_Bound => Low_Bound => Lo,
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Index_Typ, Loc),
Attribute_Name => Name_First),
High_Bound => High_Bound =>
Make_Op_Subtract (Loc, Make_Op_Subtract (Loc,
Left_Opnd => Left_Opnd =>
Make_Op_Add (Loc, Make_Op_Add (Loc,
Left_Opnd => Left_Opnd => New_Copy_Tree (Lo),
Make_Attribute_Reference (Loc, Right_Opnd =>
Prefix => New_Occurrence_Of (Index_Typ, Loc), Make_Integer_Literal (Loc,
Attribute_Name => Name_First), String_Literal_Length (Literal_Typ))),
Right_Opnd => Make_Integer_Literal (Loc,
String_Literal_Length (Literal_Typ))),
Right_Opnd => Make_Integer_Literal (Loc, 1))); Right_Opnd => Make_Integer_Literal (Loc, 1)));
end Make_Literal_Range; end Make_Literal_Range;
...@@ -2867,7 +2865,8 @@ package body Exp_Util is ...@@ -2867,7 +2865,8 @@ package body Exp_Util is
-- regressions that are not fully understood yet. -- regressions that are not fully understood yet.
elsif Nkind (Exp) = N_Type_Conversion elsif Nkind (Exp) = N_Type_Conversion
and then not Name_Req and then (not Is_Elementary_Type (Underlying_Type (Exp_Type))
or else Nkind (Parent (Exp)) = N_Assignment_Statement)
then then
Remove_Side_Effects (Expression (Exp), Variable_Ref); Remove_Side_Effects (Expression (Exp), Variable_Ref);
Scope_Suppress := Svg_Suppress; Scope_Suppress := Svg_Suppress;
......
...@@ -976,7 +976,7 @@ package body Prj.Nmsc is ...@@ -976,7 +976,7 @@ package body Prj.Nmsc is
Naming.Dot_Repl_Loc); Naming.Dot_Repl_Loc);
end if; end if;
-- Suffixs cannot -- Suffixes cannot
-- - be empty -- - be empty
-- - start with an alphanumeric -- - start with an alphanumeric
-- - start with an '_' followed by an alphanumeric -- - start with an '_' followed by an alphanumeric
...@@ -1952,7 +1952,8 @@ package body Prj.Nmsc is ...@@ -1952,7 +1952,8 @@ package body Prj.Nmsc is
if not MLib.Tgt.Libraries_Are_Supported then if not MLib.Tgt.Libraries_Are_Supported then
Error_Msg ("?libraries are not supported on this platform", Error_Msg ("?libraries are not supported on this platform",
Lib_Name.Location); Lib_Name.Location);
Data.Library := False;
else else
if Current_Verbosity = High then if Current_Verbosity = High then
...@@ -1983,12 +1984,11 @@ package body Prj.Nmsc is ...@@ -1983,12 +1984,11 @@ package body Prj.Nmsc is
declare declare
Kind_Name : constant String := Kind_Name : constant String :=
To_Lower (Name_Buffer (1 .. Name_Len)); To_Lower (Name_Buffer (1 .. Name_Len));
OK : Boolean := True; OK : Boolean := True;
begin begin
if Kind_Name = "static" then if Kind_Name = "static" then
Data.Library_Kind := Static; Data.Library_Kind := Static;
......
...@@ -3827,6 +3827,7 @@ package body Sem_Ch3 is ...@@ -3827,6 +3827,7 @@ package body Sem_Ch3 is
Set_Freeze_Node (Full_Der, Empty); Set_Freeze_Node (Full_Der, Empty);
Set_Depends_On_Private (Full_Der, Set_Depends_On_Private (Full_Der,
Has_Private_Component (Full_Der)); Has_Private_Component (Full_Der));
Set_Public_Status (Full_Der);
end if; end if;
end if; end if;
......
...@@ -1045,11 +1045,11 @@ package body Sem_Eval is ...@@ -1045,11 +1045,11 @@ package body Sem_Eval is
-- both operands are static (RM 4.9(7), 4.9(21)). -- both operands are static (RM 4.9(7), 4.9(21)).
procedure Eval_Concatenation (N : Node_Id) is procedure Eval_Concatenation (N : Node_Id) is
Left : constant Node_Id := Left_Opnd (N); Left : constant Node_Id := Left_Opnd (N);
Right : constant Node_Id := Right_Opnd (N); Right : constant Node_Id := Right_Opnd (N);
C_Typ : constant Entity_Id := Root_Type (Component_Type (Etype (N)));
Stat : Boolean; Stat : Boolean;
Fold : Boolean; Fold : Boolean;
C_Typ : constant Entity_Id := Root_Type (Component_Type (Etype (N)));
begin begin
-- Concatenation is never static in Ada 83, so if Ada 83 -- Concatenation is never static in Ada 83, so if Ada 83
...@@ -1090,6 +1090,7 @@ package body Sem_Eval is ...@@ -1090,6 +1090,7 @@ package body Sem_Eval is
declare declare
Left_Str : constant Node_Id := Get_String_Val (Left); Left_Str : constant Node_Id := Get_String_Val (Left);
Left_Len : Nat;
Right_Str : constant Node_Id := Get_String_Val (Right); Right_Str : constant Node_Id := Get_String_Val (Right);
begin begin
...@@ -1101,10 +1102,12 @@ package body Sem_Eval is ...@@ -1101,10 +1102,12 @@ package body Sem_Eval is
-- case of a concatenation of a series of string literals. -- case of a concatenation of a series of string literals.
if Nkind (Left_Str) = N_String_Literal then if Nkind (Left_Str) = N_String_Literal then
Left_Len := String_Length (Strval (Left_Str));
Start_String (Strval (Left_Str)); Start_String (Strval (Left_Str));
else else
Start_String; Start_String;
Store_String_Char (Char_Literal_Value (Left_Str)); Store_String_Char (Char_Literal_Value (Left_Str));
Left_Len := 1;
end if; end if;
-- Now append the characters of the right operand -- Now append the characters of the right operand
...@@ -1125,6 +1128,17 @@ package body Sem_Eval is ...@@ -1125,6 +1128,17 @@ package body Sem_Eval is
Set_Is_Static_Expression (N, Stat); Set_Is_Static_Expression (N, Stat);
if Stat then if Stat then
-- If left operand is the empty string, the result is the
-- right operand, including its bounds if anomalous.
if Left_Len = 0
and then Is_Array_Type (Etype (Right))
and then Etype (Right) /= Any_String
then
Set_Etype (N, Etype (Right));
end if;
Fold_Str (N, End_String); Fold_Str (N, End_String);
end if; end if;
end; end;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment