[multiple changes]

2017-11-16  Sylvain Dailler  <dailler@adacore.com>

	* sem_util.adb (Get_Enum_Lit_From_Pos): Add a condition for Pos
	lower than 0.

2017-11-16  Bob Duff  <duff@adacore.com>

	* sem_ch13.adb (Check_Expr_Constants): Avoid error message in case of
	System'To_Address.

From-SVN: r254818
This commit is contained in:
Pierre-Marie de Rodat 2017-11-16 12:53:46 +00:00
parent c757ad4cf6
commit 403bc026ac
3 changed files with 25 additions and 0 deletions

View File

@ -1,3 +1,13 @@
2017-11-16 Sylvain Dailler <dailler@adacore.com>
* sem_util.adb (Get_Enum_Lit_From_Pos): Add a condition for Pos
lower than 0.
2017-11-16 Bob Duff <duff@adacore.com>
* sem_ch13.adb (Check_Expr_Constants): Avoid error message in case of
System'To_Address.
2017-11-16 Yannick Moy <moy@adacore.com>
* sem_elab.adb (Include): Fix mode of parameter Curr to out.

View File

@ -9783,6 +9783,15 @@ package body Sem_Ch13 is
then
Check_At_Constant_Address (Prefix (Nod));
-- Normally, System'To_Address will have been transformed into
-- an Unchecked_Conversion, but in -gnatc mode, it will not,
-- and we don't want to give an error, because the whole point
-- of 'To_Address is that it is static.
elsif Attribute_Name (Nod) = Name_To_Address then
pragma Assert (Operating_Mode = Check_Semantics);
null;
else
Check_Expr_Constants (Prefix (Nod));
Check_List_Constants (Expressions (Nod));

View File

@ -9085,6 +9085,12 @@ package body Sem_Util is
end if;
Lit := First_Literal (Btyp);
-- Position in the enumeration type starts at 0.
if UI_To_Int (Pos) < 0 then
raise Constraint_Error;
end if;
for J in 1 .. UI_To_Int (Pos) loop
Next_Literal (Lit);