Commit 6fd0a72a by Arnaud Charlet

[multiple changes]

2014-01-20  Robert Dewar  <dewar@adacore.com>

	* exp_ch9.adb, checks.adb, exp_intr.adb: Minor reformatting.
	* sem_res.adb (Resolve): Fix error causing infinite loop for
	integer used as address. Allow addresses as integers.

2014-01-20  Arnaud Charlet  <charlet@adacore.com>

	* s-osinte-linux.ads (struct_sigaction): Fix rep clause.

2014-01-20  Bob Duff  <duff@adacore.com>

	* par-ch8.adb (P_Use_Type_Clause): Detect syntax
	error when "use all" is not followed by "type".

From-SVN: r206829
parent 3b4598a7
2014-01-20 Robert Dewar <dewar@adacore.com>
* exp_ch9.adb, checks.adb, exp_intr.adb: Minor reformatting.
* sem_res.adb (Resolve): Fix error causing infinite loop for
integer used as address. Allow addresses as integers.
2014-01-20 Arnaud Charlet <charlet@adacore.com>
* s-osinte-linux.ads (struct_sigaction): Fix rep clause.
2014-01-20 Bob Duff <duff@adacore.com>
* par-ch8.adb (P_Use_Type_Clause): Detect syntax
error when "use all" is not followed by "type".
2014-01-20 Bob Duff <duff@adacore.com> 2014-01-20 Bob Duff <duff@adacore.com>
* exp_intr.adb (Expand_Unc_Deallocation): Remove warning on abort * exp_intr.adb (Expand_Unc_Deallocation): Remove warning on abort
......
...@@ -767,9 +767,11 @@ package body Checks is ...@@ -767,9 +767,11 @@ package body Checks is
and then not Warnings_Off (E) and then not Warnings_Off (E)
and then Restriction_Active (No_Exception_Propagation) and then Restriction_Active (No_Exception_Propagation)
then then
Error_Msg_N ("address value may be incompatible with " & Error_Msg_N
"alignment of object?", N); ("address value may be incompatible with alignment of object?",
N);
end if; end if;
return; return;
end if; end if;
......
...@@ -1018,11 +1018,12 @@ package body Exp_Intr is ...@@ -1018,11 +1018,12 @@ package body Exp_Intr is
-- For a task type, call Free_Task before freeing the ATCB -- For a task type, call Free_Task before freeing the ATCB
if Is_Task_Type (Desig_T) then if Is_Task_Type (Desig_T) then
-- We used to detect the case of Abort followed by a Free here, -- We used to detect the case of Abort followed by a Free here,
-- because the Free wouldn't actually free if it happens before the -- because the Free wouldn't actually free if it happens before
-- aborted task actually terminates. The warning is removed, because -- the aborted task actually terminates. The warning was removed,
-- Free now works properly (the task will be freed once it -- because Free now works properly (the task will be freed once
-- terminates). -- it terminates).
Append_To Append_To
(Stmts, Cleanup_Task (N, Duplicate_Subexpr_No_Checks (Arg))); (Stmts, Cleanup_Task (N, Duplicate_Subexpr_No_Checks (Arg)));
......
...@@ -1239,8 +1239,9 @@ If the configuration pragma ...@@ -1239,8 +1239,9 @@ If the configuration pragma
@code{Allow_Integer_Address} is given, then integer expressions may @code{Allow_Integer_Address} is given, then integer expressions may
be used anywhere a value of type @code{System.Address} is required. be used anywhere a value of type @code{System.Address} is required.
The effect is to introduce an implicit unchecked conversion from the The effect is to introduce an implicit unchecked conversion from the
integer value to type @code{System.Address}. The following example integer value to type @code{System.Address}. The reverse case of using
compiles without errors: an address where an integer type is required is handled analogously.
The following example compiles without errors:
@smallexample @c ada @smallexample @c ada
pragma Allow_Integer_Address; pragma Allow_Integer_Address;
...@@ -1253,6 +1254,8 @@ package AddrAsInt is ...@@ -1253,6 +1254,8 @@ package AddrAsInt is
m : Address := 16#4000#; m : Address := 16#4000#;
n : constant Address := 4000; n : constant Address := 4000;
p : constant Address := Address (X + Y); p : constant Address := Address (X + Y);
v : Integer := y'Address;
w : constant Integer := Integer (Y'Address);
type R is new integer; type R is new integer;
RR : R := 1000; RR : R := 1000;
Z : Integer; Z : Integer;
......
...@@ -113,7 +113,12 @@ package body Ch8 is ...@@ -113,7 +113,12 @@ package body Ch8 is
Error_Msg_Ada_2012_Feature ("|`USE ALL TYPE`", Token_Ptr); Error_Msg_Ada_2012_Feature ("|`USE ALL TYPE`", Token_Ptr);
All_Present := True; All_Present := True;
Scan; -- past ALL Scan; -- past ALL
else
if Token /= Tok_Type then
Error_Msg_SC ("TYPE expected");
end if;
else pragma Assert (Token = Tok_Type);
All_Present := False; All_Present := False;
end if; end if;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1991-1994, Florida State University -- -- Copyright (C) 1991-1994, Florida State University --
-- Copyright (C) 1995-2012, Free Software Foundation, Inc. -- -- Copyright (C) 1995-2013, 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- --
...@@ -589,7 +589,8 @@ private ...@@ -589,7 +589,8 @@ private
for struct_sigaction use record for struct_sigaction use record
sa_handler at Linux.sa_handler_pos range 0 .. Standard'Address_Size - 1; sa_handler at Linux.sa_handler_pos range 0 .. Standard'Address_Size - 1;
sa_mask at Linux.sa_mask_pos range 0 .. 1023; sa_mask at Linux.sa_mask_pos range 0 .. 1023;
sa_flags at Linux.sa_flags_pos range 0 .. Standard'Address_Size - 1; sa_flags at Linux.sa_flags_pos
range 0 .. Interfaces.C.unsigned_long'Size - 1;
end record; end record;
-- We intentionally leave sa_restorer unspecified and let the compiler -- We intentionally leave sa_restorer unspecified and let the compiler
-- append it after the last field, so disable corresponding warning. -- append it after the last field, so disable corresponding warning.
......
...@@ -2612,30 +2612,36 @@ package body Sem_Res is ...@@ -2612,30 +2612,36 @@ package body Sem_Res is
end; end;
end if; end if;
-- If an error message was issued already, Found got reset to -- Looks like we have a type error, but check for special case
-- True, so if it is still False, issue standard Wrong_Type msg. -- of Address wanted, integer found, with the configuration pragma
-- Allow_Integer_Address active. If we have this case, introduce
-- First check for special case of Address wanted, integer found -- an unchecked conversion to allow the integer expression to be
-- with the configuration pragma Allow_Integer_Address active. -- treated as an Address. The reverse case of integer wanted,
-- Address found, is treated in an analogous manner.
if Allow_Integer_Address
and then Is_RTE (Typ, RE_Address) if Allow_Integer_Address then
and then Is_Integer_Type (Etype (N)) if (Is_RTE (Typ, RE_Address)
then and then Is_Integer_Type (Etype (N)))
Rewrite or else
(N, Unchecked_Convert_To (RTE (RE_Address), (Is_Integer_Type (Typ)
Relocate_Node (N))); and then Is_RTE (Etype (N), RE_Address))
Analyze_And_Resolve (N, RTE (RE_Address)); then
return; Rewrite (N, Unchecked_Convert_To (Typ, Relocate_Node (N)));
Analyze_And_Resolve (N, Typ);
return;
end if;
end if;
-- OK, not the special case go ahead and issue message -- That special Allow_Integer_Address check did not appply, so we
-- have a real type error. If an error message was issued already,
-- Found got reset to True, so if it's still False, issue standard
-- Wrong_Type message.
elsif not Found then if not Found then
if Is_Overloaded (N) if Is_Overloaded (N) and then Nkind (N) = N_Function_Call then
and then Nkind (N) = N_Function_Call
then
declare declare
Subp_Name : Node_Id; Subp_Name : Node_Id;
begin begin
if Is_Entity_Name (Name (N)) then if Is_Entity_Name (Name (N)) then
Subp_Name := Name (N); Subp_Name := Name (N);
...@@ -11085,6 +11091,23 @@ package body Sem_Res is ...@@ -11085,6 +11091,23 @@ package body Sem_Res is
end; end;
end if; end if;
-- Deal with conversion of integer type to address if the pragma
-- Allow_Integer_Address is in effect. We convert the conversion to
-- an unchecked conversion in this case and we are all done!
if Allow_Integer_Address
and then
((Is_RTE (Target_Type, RE_Address)
and then Is_Integer_Type (Opnd_Type))
or else
(Is_RTE (Opnd_Type, RE_Address)
and then Is_Integer_Type (Target_Type)))
then
Rewrite (N, Unchecked_Convert_To (Target_Type, Expression (N)));
Analyze_And_Resolve (N, Target_Type);
return True;
end if;
-- If we are within a child unit, check whether the type of the -- If we are within a child unit, check whether the type of the
-- expression has an ancestor in a parent unit, in which case it -- expression has an ancestor in a parent unit, in which case it
-- belongs to its derivation class even if the ancestor is private. -- belongs to its derivation class even if the ancestor is private.
...@@ -11094,7 +11117,7 @@ package body Sem_Res is ...@@ -11094,7 +11117,7 @@ package body Sem_Res is
-- Numeric types -- Numeric types
if Is_Numeric_Type (Target_Type) then if Is_Numeric_Type (Target_Type) then
-- A universal fixed expression can be converted to any numeric type -- A universal fixed expression can be converted to any numeric type
...@@ -11120,11 +11143,11 @@ package body Sem_Res is ...@@ -11120,11 +11143,11 @@ package body Sem_Res is
else else
return Conversion_Check return Conversion_Check
(Is_Numeric_Type (Opnd_Type) (Is_Numeric_Type (Opnd_Type)
or else or else
(Present (Inc_Ancestor) (Present (Inc_Ancestor)
and then Is_Numeric_Type (Inc_Ancestor)), and then Is_Numeric_Type (Inc_Ancestor)),
"illegal operand for numeric conversion"); "illegal operand for numeric conversion");
end if; end if;
-- Array types -- Array types
...@@ -11637,18 +11660,6 @@ package body Sem_Res is ...@@ -11637,18 +11660,6 @@ package body Sem_Res is
("add ALL to }!", N, Target_Type); ("add ALL to }!", N, Target_Type);
return False; return False;
-- Deal with conversion of integer type to address if the pragma
-- Allow_Integer_Address is in effect.
elsif Allow_Integer_Address
and then Is_RTE (Etype (N), RE_Address)
and then Is_Integer_Type (Etype (Operand))
then
Rewrite (N,
Unchecked_Convert_To (RTE (RE_Address), Relocate_Node (N)));
Analyze_And_Resolve (N, RTE (RE_Address));
return True;
-- Here we have a real conversion error -- Here we have a real conversion error
else else
......
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