Commit 13f34a3f by Robert Dewar Committed by Arnaud Charlet

sem_eval.adb (Eval_Relational_Op): nothing to do if an operand is an illegal…

sem_eval.adb (Eval_Relational_Op): nothing to do if an operand is an illegal aggregate and the type is still...

2007-04-20  Robert Dewar  <dewar@adacore.com>

	* sem_eval.adb (Eval_Relational_Op): nothing to do if an operand is an
	illegal aggregate and the type is still Any_Composite.
	(Subtypes_Statically_Match): Fix problem of empty discriminant list

From-SVN: r125460
parent 79e44845
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -33,6 +33,7 @@ with Errout; use Errout; ...@@ -33,6 +33,7 @@ with Errout; use Errout;
with Eval_Fat; use Eval_Fat; with Eval_Fat; use Eval_Fat;
with Exp_Util; use Exp_Util; with Exp_Util; use Exp_Util;
with Lib; use Lib; with Lib; use Lib;
with Namet; use Namet;
with Nmake; use Nmake; with Nmake; use Nmake;
with Nlists; use Nlists; with Nlists; use Nlists;
with Opt; use Opt; with Opt; use Opt;
...@@ -2262,11 +2263,13 @@ package body Sem_Eval is ...@@ -2262,11 +2263,13 @@ package body Sem_Eval is
-- then we can replace the entire result by False. We only -- then we can replace the entire result by False. We only
-- do this for one dimensional arrays, because the case of -- do this for one dimensional arrays, because the case of
-- multi-dimensional arrays is rare and too much trouble! -- multi-dimensional arrays is rare and too much trouble!
-- If one of the operands is an illegal aggregate, its type
-- might still be an arbitrary composite type, so nothing to do.
if Is_Array_Type (Typ) if Is_Array_Type (Typ)
and then Typ /= Any_Composite
and then Number_Dimensions (Typ) = 1 and then Number_Dimensions (Typ) = 1
and then (Nkind (N) = N_Op_Eq and then (Nkind (N) = N_Op_Eq or else Nkind (N) = N_Op_Ne)
or else Nkind (N) = N_Op_Ne)
then then
if Raises_Constraint_Error (Left) if Raises_Constraint_Error (Left)
or else Raises_Constraint_Error (Right) or else Raises_Constraint_Error (Right)
...@@ -2276,9 +2279,9 @@ package body Sem_Eval is ...@@ -2276,9 +2279,9 @@ package body Sem_Eval is
declare declare
procedure Get_Static_Length (Op : Node_Id; Len : out Uint); procedure Get_Static_Length (Op : Node_Id; Len : out Uint);
-- If Op is an expression for a constrained array with a -- If Op is an expression for a constrained array with a known
-- known at compile time length, then Len is set to this -- at compile time length, then Len is set to this (non-negative
-- (non-negative length). Otherwise Len is set to minus 1. -- length). Otherwise Len is set to minus 1.
----------------------- -----------------------
-- Get_Static_Length -- -- Get_Static_Length --
...@@ -2963,9 +2966,9 @@ package body Sem_Eval is ...@@ -2963,9 +2966,9 @@ package body Sem_Eval is
Val : Uint; Val : Uint;
begin begin
-- If already in cache, then we know it's compile time known and -- If already in cache, then we know it's compile time known and we can
-- we can return the value that was previously stored in the cache -- return the value that was previously stored in the cache since
-- since compile time known values cannot change :-) -- compile time known values cannot change.
if CV_Ent.N = N then if CV_Ent.N = N then
return CV_Ent.V; return CV_Ent.V;
...@@ -4092,17 +4095,24 @@ package body Sem_Eval is ...@@ -4092,17 +4095,24 @@ package body Sem_Eval is
DL1 : constant Elist_Id := Discriminant_Constraint (T1); DL1 : constant Elist_Id := Discriminant_Constraint (T1);
DL2 : constant Elist_Id := Discriminant_Constraint (T2); DL2 : constant Elist_Id := Discriminant_Constraint (T2);
DA1 : Elmt_Id := First_Elmt (DL1); DA1 : Elmt_Id;
DA2 : Elmt_Id := First_Elmt (DL2); DA2 : Elmt_Id;
begin begin
if DL1 = DL2 then if DL1 = DL2 then
return True; return True;
elsif Is_Constrained (T1) /= Is_Constrained (T2) then elsif Is_Constrained (T1) /= Is_Constrained (T2) then
return False; return False;
end if; end if;
-- Now loop through the discriminant constraints
-- Note: the guard here seems necessary, since it is possible at
-- least for DL1 to be No_Elist. Not clear this is reasonable ???
if Present (DL1) and then Present (DL2) then
DA1 := First_Elmt (DL1);
DA2 := First_Elmt (DL2);
while Present (DA1) loop while Present (DA1) loop
declare declare
Expr1 : constant Node_Id := Node (DA1); Expr1 : constant Node_Id := Node (DA1);
...@@ -4131,6 +4141,7 @@ package body Sem_Eval is ...@@ -4131,6 +4141,7 @@ package body Sem_Eval is
Next_Elmt (DA1); Next_Elmt (DA1);
Next_Elmt (DA2); Next_Elmt (DA2);
end loop; end loop;
end if;
end; end;
return True; return True;
......
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