Commit 70805b88 by Arnaud Charlet

[multiple changes]

2012-07-16  Robert Dewar  <dewar@adacore.com>

	* a-exexpr.adb, freeze.adb, a-exexpr-gcc.adb, a-except-2005.adb,
	sem_eval.adb, s-fileio.adb: Minor reformatting.

2012-07-16  Javier Miranda  <miranda@adacore.com>

	* sem_prag.adb (Analyze_Pragma): Remove support for obsolescent
	pragma CPP_Class.
	* sem_ch13.adb (Analyze_Freeze_Entity): Add missing error on Ada
	derivations of CPP types.  Found updating the tests affected by
	the removal of pragma CPP_Class.

2012-07-16  Thomas Quinot  <quinot@adacore.com>

	* back_end.adb: Minor reformatting.

2012-07-16  Thomas Quinot  <quinot@adacore.com>

	* exp_ch9.adb (Expand_N_Selective_Accept.Process_Accept_Alternative):
	Remove junk test that was always true. For the case of no statements
	following the ACCEPT, jump directly to End_Lab instead of
	introducing an intermediate jump.
	(Expand_N_Selective_Accept.Process_Delay_Alternative): Fix
	predicate testing for presence of statements following the DELAY.
	that was always true. For the case of no statements following
	the ACCEPT, jump directly to End_Lab instead of introducing an
	intermediate jump.
	(Expand_N_Selective_Accept): Fix incorrect insertion point for
	end label.

From-SVN: r189534
parent be93c386
2012-07-16 Robert Dewar <dewar@adacore.com>
* a-exexpr.adb, freeze.adb, a-exexpr-gcc.adb, a-except-2005.adb,
sem_eval.adb, s-fileio.adb: Minor reformatting.
2012-07-16 Javier Miranda <miranda@adacore.com>
* sem_prag.adb (Analyze_Pragma): Remove support for obsolescent
pragma CPP_Class.
* sem_ch13.adb (Analyze_Freeze_Entity): Add missing error on Ada
derivations of CPP types. Found updating the tests affected by
the removal of pragma CPP_Class.
2012-07-16 Thomas Quinot <quinot@adacore.com>
* back_end.adb: Minor reformatting.
2012-07-16 Thomas Quinot <quinot@adacore.com>
* exp_ch9.adb (Expand_N_Selective_Accept.Process_Accept_Alternative):
Remove junk test that was always true. For the case of no statements
following the ACCEPT, jump directly to End_Lab instead of
introducing an intermediate jump.
(Expand_N_Selective_Accept.Process_Delay_Alternative): Fix
predicate testing for presence of statements following the DELAY.
that was always true. For the case of no statements following
the ACCEPT, jump directly to End_Lab instead of introducing an
intermediate jump.
(Expand_N_Selective_Accept): Fix incorrect insertion point for
end label.
2012-07-16 Thomas Quinot <quinot@adacore.com> 2012-07-16 Thomas Quinot <quinot@adacore.com>
* gnat_rm.texi: Minor documentation improvements. * gnat_rm.texi: Minor documentation improvements.
......
...@@ -274,22 +274,21 @@ package body Ada.Exceptions is ...@@ -274,22 +274,21 @@ package body Ada.Exceptions is
function Create_Occurrence_From_Signal_Handler function Create_Occurrence_From_Signal_Handler
(E : Exception_Id; (E : Exception_Id;
M : System.Address) M : System.Address) return EOA;
return EOA;
-- Create and build an exception occurrence using exception id E and -- Create and build an exception occurrence using exception id E and
-- nul-terminated message M. -- nul-terminated message M.
function Create_Machine_Occurrence_From_Signal_Handler function Create_Machine_Occurrence_From_Signal_Handler
(E : Exception_Id; (E : Exception_Id;
M : System.Address) M : System.Address) return System.Address;
return System.Address;
pragma Export (C, Create_Machine_Occurrence_From_Signal_Handler, pragma Export (C, Create_Machine_Occurrence_From_Signal_Handler,
"__gnat_create_machine_occurrence_from_signal_handler"); "__gnat_create_machine_occurrence_from_signal_handler");
-- Create and build an exception occurrence using exception id E and -- Create and build an exception occurrence using exception id E and
-- nul-terminated message M. Return the machine occurrence. -- nul-terminated message M. Return the machine occurrence.
procedure Raise_Exception_No_Defer procedure Raise_Exception_No_Defer
(E : Exception_Id; Message : String := ""); (E : Exception_Id;
Message : String := "");
pragma Export pragma Export
(Ada, Raise_Exception_No_Defer, (Ada, Raise_Exception_No_Defer,
"ada__exceptions__raise_exception_no_defer"); "ada__exceptions__raise_exception_no_defer");
...@@ -1051,10 +1050,10 @@ package body Ada.Exceptions is ...@@ -1051,10 +1050,10 @@ package body Ada.Exceptions is
function Create_Occurrence_From_Signal_Handler function Create_Occurrence_From_Signal_Handler
(E : Exception_Id; (E : Exception_Id;
M : System.Address) M : System.Address) return EOA
return EOA
is is
X : constant EOA := Exception_Propagation.Allocate_Occurrence; X : constant EOA := Exception_Propagation.Allocate_Occurrence;
begin begin
Exception_Data.Set_Exception_C_Msg (X, E, M); Exception_Data.Set_Exception_C_Msg (X, E, M);
...@@ -1072,8 +1071,7 @@ package body Ada.Exceptions is ...@@ -1072,8 +1071,7 @@ package body Ada.Exceptions is
function Create_Machine_Occurrence_From_Signal_Handler function Create_Machine_Occurrence_From_Signal_Handler
(E : Exception_Id; (E : Exception_Id;
M : System.Address) M : System.Address) return System.Address
return System.Address
is is
begin begin
return Create_Occurrence_From_Signal_Handler (E, M).Machine_Occurrence; return Create_Occurrence_From_Signal_Handler (E, M).Machine_Occurrence;
......
...@@ -203,8 +203,7 @@ package body Exception_Propagation is ...@@ -203,8 +203,7 @@ package body Exception_Propagation is
-- directly from gigi. -- directly from gigi.
function Setup_Current_Excep function Setup_Current_Excep
(GCC_Exception : not null GCC_Exception_Access) (GCC_Exception : not null GCC_Exception_Access) return EOA;
return EOA;
pragma Export (C, Setup_Current_Excep, "__gnat_setup_current_excep"); pragma Export (C, Setup_Current_Excep, "__gnat_setup_current_excep");
-- Write Get_Current_Excep.all from GCC_Exception -- Write Get_Current_Excep.all from GCC_Exception
...@@ -344,8 +343,7 @@ package body Exception_Propagation is ...@@ -344,8 +343,7 @@ package body Exception_Propagation is
------------------------- -------------------------
function Setup_Current_Excep function Setup_Current_Excep
(GCC_Exception : not null GCC_Exception_Access) (GCC_Exception : not null GCC_Exception_Access) return EOA
return EOA
is is
Excep : constant EOA := Get_Current_Excep.all; Excep : constant EOA := Get_Current_Excep.all;
...@@ -427,6 +425,7 @@ package body Exception_Propagation is ...@@ -427,6 +425,7 @@ package body Exception_Propagation is
(GCC_Exception : not null GCC_Exception_Access) (GCC_Exception : not null GCC_Exception_Access)
is is
Excep : EOA; Excep : EOA;
begin begin
-- Perform a standard raise first. If a regular handler is found, it -- Perform a standard raise first. If a regular handler is found, it
-- will be entered after all the intermediate cleanups have run. If -- will be entered after all the intermediate cleanups have run. If
......
...@@ -65,6 +65,7 @@ package body Exception_Propagation is ...@@ -65,6 +65,7 @@ package body Exception_Propagation is
procedure Propagate_Exception (Excep : EOA) is procedure Propagate_Exception (Excep : EOA) is
Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all; Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all;
begin begin
-- If the jump buffer pointer is non-null, transfer control using -- If the jump buffer pointer is non-null, transfer control using
-- it. Otherwise announce an unhandled exception (note that this -- it. Otherwise announce an unhandled exception (note that this
......
...@@ -237,7 +237,7 @@ package body Back_End is ...@@ -237,7 +237,7 @@ package body Back_End is
elsif Switch_Chars (First .. Last) = "fpreserve-control-flow" then elsif Switch_Chars (First .. Last) = "fpreserve-control-flow" then
Opt.Suppress_Control_Flow_Optimizations := True; Opt.Suppress_Control_Flow_Optimizations := True;
-- Back end switcg -fdump-scos, which exists primarily for C, is -- Back end switch -fdump-scos, which exists primarily for C, is
-- also accepted for Ada as a synonym of -gnateS. -- also accepted for Ada as a synonym of -gnateS.
elsif Switch_Chars (First .. Last) = "fdump-scos" then elsif Switch_Chars (First .. Last) = "fdump-scos" then
......
...@@ -1041,8 +1041,9 @@ package body Freeze is ...@@ -1041,8 +1041,9 @@ package body Freeze is
Comp_Type := Etype (Comp); Comp_Type := Etype (Comp);
Comp_Def := Component_Definition (Parent (Comp)); Comp_Def := Component_Definition (Parent (Comp));
Comp_Byte_Aligned := Present (Component_Clause (Comp)) Comp_Byte_Aligned :=
and then Normalized_First_Bit (Comp) mod System_Storage_Unit = 0; Present (Component_Clause (Comp))
and then Normalized_First_Bit (Comp) mod System_Storage_Unit = 0;
-- Array case -- Array case
......
...@@ -626,7 +626,6 @@ package body System.File_IO is ...@@ -626,7 +626,6 @@ package body System.File_IO is
then then
Start := J + 1; Start := J + 1;
Stop := Start - 1; Stop := Start - 1;
while Form (Stop + 1) /= ASCII.NUL while Form (Stop + 1) /= ASCII.NUL
and then Form (Stop + 1) /= ',' and then Form (Stop + 1) /= ','
loop loop
......
...@@ -48,6 +48,7 @@ with Sem_Ch6; use Sem_Ch6; ...@@ -48,6 +48,7 @@ with Sem_Ch6; use Sem_Ch6;
with Sem_Ch8; use Sem_Ch8; with Sem_Ch8; use Sem_Ch8;
with Sem_Ch9; use Sem_Ch9; with Sem_Ch9; use Sem_Ch9;
with Sem_Dim; use Sem_Dim; with Sem_Dim; use Sem_Dim;
with Sem_Disp; use Sem_Disp;
with Sem_Eval; use Sem_Eval; with Sem_Eval; use Sem_Eval;
with Sem_Res; use Sem_Res; with Sem_Res; use Sem_Res;
with Sem_Type; use Sem_Type; with Sem_Type; use Sem_Type;
...@@ -4322,6 +4323,46 @@ package body Sem_Ch13 is ...@@ -4322,6 +4323,46 @@ package body Sem_Ch13 is
end; end;
end if; end if;
-- Check Ada derivation of CPP type
if Expander_Active
and then Tagged_Type_Expansion
and then Ekind (E) = E_Record_Type
and then Etype (E) /= E
and then Is_CPP_Class (Etype (E))
and then CPP_Num_Prims (Etype (E)) > 0
and then not Is_CPP_Class (E)
and then not Has_CPP_Constructors (Etype (E))
then
-- If the parent has C++ primitives but it has no constructor then
-- check that all the primitives are overridden in this derivation;
-- otherwise the constructor of the parent is needed to build the
-- dispatch table.
declare
Elmt : Elmt_Id;
Prim : Node_Id;
begin
Elmt := First_Elmt (Primitive_Operations (E));
while Present (Elmt) loop
Prim := Node (Elmt);
if not Is_Abstract_Subprogram (Prim)
and then No (Interface_Alias (Prim))
and then Find_Dispatching_Type (Ultimate_Alias (Prim)) /= E
then
Error_Msg_Name_1 := Chars (Etype (E));
Error_Msg_N
("'C'P'P constructor required for parent type %", E);
exit;
end if;
Next_Elmt (Elmt);
end loop;
end;
end if;
Inside_Freezing_Actions := Inside_Freezing_Actions - 1; Inside_Freezing_Actions := Inside_Freezing_Actions - 1;
-- If we have a type with predicates, build predicate function -- If we have a type with predicates, build predicate function
......
...@@ -218,12 +218,12 @@ package body Sem_Eval is ...@@ -218,12 +218,12 @@ package body Sem_Eval is
-- If Fold and Stat are both set to False then this routine performs also -- If Fold and Stat are both set to False then this routine performs also
-- the following extra actions: -- the following extra actions:
-- --
-- * If either operand is Any_Type then propagate it to result to -- If either operand is Any_Type then propagate it to result to
-- prevent cascaded errors. -- prevent cascaded errors.
-- --
-- * If some operand raises constraint error, then replace the node N -- If some operand raises constraint error, then replace the node N
-- with the raise constraint error node. This replacement inherits the -- with the raise constraint error node. This replacement inherits the
-- Is_Static_Expression flag from the operands. -- Is_Static_Expression flag from the operands.
procedure Test_Expression_Is_Foldable procedure Test_Expression_Is_Foldable
(N : Node_Id; (N : Node_Id;
......
...@@ -4690,6 +4690,12 @@ package body Sem_Prag is ...@@ -4690,6 +4690,12 @@ package body Sem_Prag is
Get_Pragma_Arg (Arg2)); Get_Pragma_Arg (Arg2));
end if; end if;
if Etype (Def_Id) /= Def_Id
and then not Is_CPP_Class (Root_Type (Def_Id))
then
Error_Msg_N ("root type must be a 'C'P'P type", Arg1);
end if;
Set_Is_CPP_Class (Def_Id); Set_Is_CPP_Class (Def_Id);
-- Imported CPP types must not have discriminants (because C++ -- Imported CPP types must not have discriminants (because C++
...@@ -7651,108 +7657,13 @@ package body Sem_Prag is ...@@ -7651,108 +7657,13 @@ package body Sem_Prag is
-- pragma CPP_Class ([Entity =>] local_NAME) -- pragma CPP_Class ([Entity =>] local_NAME)
when Pragma_CPP_Class => CPP_Class : declare when Pragma_CPP_Class => CPP_Class : declare
Arg : Node_Id;
Typ : Entity_Id;
begin begin
if Warn_On_Obsolescent_Feature then
Error_Msg_N
("'G'N'A'T pragma cpp'_class is now obsolete; replace it" &
" by pragma import?", N);
end if;
GNAT_Pragma; GNAT_Pragma;
Check_Arg_Count (1);
Check_Optional_Identifier (Arg1, Name_Entity);
Check_Arg_Is_Local_Name (Arg1);
Arg := Get_Pragma_Arg (Arg1);
Analyze (Arg);
if Etype (Arg) = Any_Type then
return;
end if;
if not Is_Entity_Name (Arg)
or else not Is_Type (Entity (Arg))
then
Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
end if;
Typ := Entity (Arg);
if not Is_Tagged_Type (Typ) then
Error_Pragma_Arg ("pragma% applicable to tagged types ", Arg1);
end if;
-- Types treated as CPP classes must be declared limited (note:
-- this used to be a warning but there is no real benefit to it
-- since we did effectively intend to treat the type as limited
-- anyway).
if not Is_Limited_Type (Typ) then if Warn_On_Obsolescent_Feature then
Error_Msg_N
("imported 'C'P'P type must be limited",
Get_Pragma_Arg (Arg1));
end if;
Set_Is_CPP_Class (Typ);
Set_Convention (Typ, Convention_CPP);
-- Imported CPP types must not have discriminants (because C++
-- classes do not have discriminants).
if Has_Discriminants (Typ) then
Error_Msg_N Error_Msg_N
("imported 'C'P'P type cannot have discriminants", ("'G'N'A'T pragma cpp'_class is now obsolete and has no " &
First (Discriminant_Specifications "effect; replace it by pragma import?", N);
(Declaration_Node (Typ))));
end if;
-- Components of imported CPP types must not have default
-- expressions because the constructor (if any) is in the
-- C++ side.
if Is_Incomplete_Or_Private_Type (Typ)
and then No (Underlying_Type (Typ))
then
-- It should be an error to apply pragma CPP to a private
-- type if the underlying type is not visible (as it is
-- for any representation item). For now, for backward
-- compatibility we do nothing but we cannot check components
-- because they are not available at this stage. All this code
-- will be removed when we cleanup this obsolete GNAT pragma???
null;
else
declare
Tdef : constant Node_Id :=
Type_Definition (Declaration_Node (Typ));
Clist : Node_Id;
Comp : Node_Id;
begin
if Nkind (Tdef) = N_Record_Definition then
Clist := Component_List (Tdef);
else
pragma Assert (Nkind (Tdef) = N_Derived_Type_Definition);
Clist := Component_List (Record_Extension_Part (Tdef));
end if;
if Present (Clist) then
Comp := First (Component_Items (Clist));
while Present (Comp) loop
if Present (Expression (Comp)) then
Error_Msg_N
("component of imported 'C'P'P type cannot have" &
" default expression", Expression (Comp));
end if;
Next (Comp);
end loop;
end if;
end;
end if; end if;
end CPP_Class; end CPP_Class;
...@@ -7802,6 +7713,12 @@ package body Sem_Prag is ...@@ -7802,6 +7713,12 @@ package body Sem_Prag is
and then and then
Is_CPP_Class (Root_Type (Etype (Def_Id))))) Is_CPP_Class (Root_Type (Etype (Def_Id)))))
then then
if Scope (Def_Id) /= Scope (Etype (Def_Id)) then
Error_Msg_N
("'C'P'P constructor must be defined in the scope of " &
"its returned type", Arg1);
end if;
if Arg_Count >= 2 then if Arg_Count >= 2 then
Set_Imported (Def_Id); Set_Imported (Def_Id);
Set_Is_Public (Def_Id); Set_Is_Public (Def_Id);
...@@ -7822,8 +7739,8 @@ package body Sem_Prag is ...@@ -7822,8 +7739,8 @@ package body Sem_Prag is
if Is_Tagged_Type (Etype (Def_Id)) if Is_Tagged_Type (Etype (Def_Id))
and then not Is_Class_Wide_Type (Etype (Def_Id)) and then not Is_Class_Wide_Type (Etype (Def_Id))
and then Is_Dispatching_Operation (Def_Id)
then then
pragma Assert (Is_Dispatching_Operation (Def_Id));
Tag_Typ := Etype (Def_Id); Tag_Typ := Etype (Def_Id);
Elmt := First_Elmt (Primitive_Operations (Tag_Typ)); Elmt := First_Elmt (Primitive_Operations (Tag_Typ));
......
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