Commit f2a35a2f by Bob Duff Committed by Pierre-Marie de Rodat

[Ada] Fix a folding issue with System'To_Address

2019-08-20  Bob Duff  <duff@adacore.com>

gcc/ada/

	* sem_eval.adb (Expr_Value): Implement the case of an unchecked
	conversion of a static expression.

From-SVN: r274726
parent d21ae867
2019-08-20 Bob Duff <duff@adacore.com> 2019-08-20 Bob Duff <duff@adacore.com>
* sem_eval.adb (Expr_Value): Implement the case of an unchecked
conversion of a static expression.
2019-08-20 Bob Duff <duff@adacore.com>
* sem_ch13.adb (Is_Null_Array): New function, used to detect the * sem_ch13.adb (Is_Null_Array): New function, used to detect the
null array case; used to warn about uncheckedly converting to a null array case; used to warn about uncheckedly converting to a
zero-sized array. It is unfortunate that we can't just check zero-sized array. It is unfortunate that we can't just check
......
...@@ -4281,10 +4281,9 @@ package body Sem_Eval is ...@@ -4281,10 +4281,9 @@ package body Sem_Eval is
pragma Assert (Is_Access_Type (Underlying_Type (Etype (N)))); pragma Assert (Is_Access_Type (Underlying_Type (Etype (N))));
Val := Uint_0; Val := Uint_0;
-- Otherwise must be character literal -- Character literal
else elsif Kind = N_Character_Literal then
pragma Assert (Kind = N_Character_Literal);
Ent := Entity (N); Ent := Entity (N);
-- Since Character literals of type Standard.Character don't -- Since Character literals of type Standard.Character don't
...@@ -4298,6 +4297,15 @@ package body Sem_Eval is ...@@ -4298,6 +4297,15 @@ package body Sem_Eval is
else else
Val := Enumeration_Pos (Ent); Val := Enumeration_Pos (Ent);
end if; end if;
-- Unchecked conversion, which can come from System'To_Address (X)
-- where X is a static integer expression. Recursively evaluate X.
elsif Kind = N_Unchecked_Type_Conversion then
Val := Expr_Value (Expression (N));
else
raise Program_Error;
end if; end if;
-- Come here with Val set to value to be returned, set cache -- Come here with Val set to value to be returned, set cache
......
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