summaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-05-06 09:33:04 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-05-06 09:33:04 +0000
commit9f4f71bdf651a7aba201068e50ec4a9fb1b1dbd4 (patch)
treea384c06f4c493401d5df423f92cdcf6f98ef5e59 /gcc/ada
parent17953e50b8ee679e0a41de4783bdddd26c13fd0b (diff)
downloadgcc-9f4f71bdf651a7aba201068e50ec4a9fb1b1dbd4.tar.gz
2009-05-06 Gary Dismukes <dismukes@adacore.com>
* sem_aggr.adb: Fix typo. 2009-05-06 Thomas Quinot <quinot@adacore.com> * exp_ch3.adb (Expand_N_Object_Declaration): For a controlled object declaration, do not adjust if the declaration is to be rewritten into a renaming. 2009-05-06 Ed Schonberg <schonberg@adacore.com> * sem_ch8.adb (Find_Type): Reject the use of a task type in its own discriminant part. 2009-05-06 Bob Duff <duff@adacore.com> * s-fileio.adb (File_IO_Clean_Up_Type): Make this type limited, since otherwise the compiler would be allowed to optimize away the cleanup code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147163 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog21
-rw-r--r--gcc/ada/exp_ch3.adb43
-rw-r--r--gcc/ada/s-fileio.adb10
-rw-r--r--gcc/ada/sem_aggr.adb8
-rw-r--r--gcc/ada/sem_ch8.adb15
5 files changed, 76 insertions, 21 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index d5b500565d1..53c2fad10c1 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,26 @@
2009-05-06 Gary Dismukes <dismukes@adacore.com>
+ * sem_aggr.adb: Fix typo.
+
+2009-05-06 Thomas Quinot <quinot@adacore.com>
+
+ * exp_ch3.adb (Expand_N_Object_Declaration): For a controlled object
+ declaration, do not adjust if the declaration is to be rewritten into
+ a renaming.
+
+2009-05-06 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch8.adb (Find_Type): Reject the use of a task type in its own
+ discriminant part.
+
+2009-05-06 Bob Duff <duff@adacore.com>
+
+ * s-fileio.adb (File_IO_Clean_Up_Type): Make this type limited, since
+ otherwise the compiler would be allowed to optimize away the cleanup
+ code.
+
+2009-05-06 Gary Dismukes <dismukes@adacore.com>
+
* gnat_ugn.texi: Fix typo.
2009-05-06 Thomas Quinot <quinot@adacore.com>
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 5ba57dea134..df4c6668cc4 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -1888,8 +1888,8 @@ package body Exp_Ch3 is
end if;
if Needs_Finalization (Typ)
- and then not (Kind = N_Aggregate or else Kind = N_Extension_Aggregate)
- and then not Is_Inherently_Limited_Type (Typ)
+ and then not (Nkind_In (Kind, N_Aggregate, N_Extension_Aggregate))
+ and then not Is_Inherently_Limited_Type (Typ)
then
Append_List_To (Res,
Make_Adjust_Call (
@@ -4185,9 +4185,28 @@ package body Exp_Ch3 is
-- which case the init proc call must be inserted only after the bodies
-- of the shared variable procedures have been seen.
+ function Rewrite_As_Renaming return Boolean;
+ -- Indicate whether to rewrite a declaration with initialization into an
+ -- object renaming declaration (see below).
+
+ -------------------------
+ -- Rewrite_As_Renaming --
+ -------------------------
+
+ function Rewrite_As_Renaming return Boolean is
+ begin
+ return not Aliased_Present (N)
+ and then Is_Entity_Name (Expr_Q)
+ and then Ekind (Entity (Expr_Q)) = E_Variable
+ and then OK_To_Rename (Entity (Expr_Q))
+ and then Is_Entity_Name (Object_Definition (N));
+ end Rewrite_As_Renaming;
+
+ -- Start of processing for Expand_N_Object_Declaration
+
begin
- -- Don't do anything for deferred constants. All proper actions will
- -- be expanded during the full declaration.
+ -- Don't do anything for deferred constants. All proper actions will be
+ -- expanded during the full declaration.
if No (Expr) and Constant_Present (N) then
return;
@@ -4603,10 +4622,13 @@ package body Exp_Ch3 is
-- where the object was initialized by a call to a function whose
-- result is built in place, since no copy occurred. (Eventually
-- we plan to support in-place function results for some cases
- -- of nonlimited types. ???)
+ -- of nonlimited types. ???) Similarly, no adjustment is required
+ -- if we are going to rewrite the object declaration into a
+ -- renaming declaration.
if Needs_Finalization (Typ)
and then not Is_Inherently_Limited_Type (Typ)
+ and then not Rewrite_As_Renaming
then
Insert_Actions_After (Init_After,
Make_Adjust_Call (
@@ -4750,14 +4772,11 @@ package body Exp_Ch3 is
-- X : typ renames expr
-- provided that X is not aliased. The aliased case has to be
- -- excluded in general because expr will not be aliased in general.
+ -- excluded in general because Expr will not be aliased in general.
+ -- We also exclude controlled types because X and Expr may need to
+ -- be attached to distinct finalization lists.
- if not Aliased_Present (N)
- and then Is_Entity_Name (Expr_Q)
- and then Ekind (Entity (Expr_Q)) = E_Variable
- and then OK_To_Rename (Entity (Expr_Q))
- and then Is_Entity_Name (Object_Definition (N))
- then
+ if Rewrite_As_Renaming then
Rewrite (N,
Make_Object_Renaming_Declaration (Loc,
Defining_Identifier => Defining_Identifier (N),
diff --git a/gcc/ada/s-fileio.adb b/gcc/ada/s-fileio.adb
index b3084775ff1..fd7adfd7044 100644
--- a/gcc/ada/s-fileio.adb
+++ b/gcc/ada/s-fileio.adb
@@ -73,12 +73,12 @@ package body System.File_IO is
-- Points to list of names of temporary files. Note that this global
-- variable must be properly protected to provide thread safety.
- type File_IO_Clean_Up_Type is new Controlled with null record;
+ type File_IO_Clean_Up_Type is new Limited_Controlled with null record;
-- The closing of all open files and deletion of temporary files is an
- -- action which takes place at the end of execution of the main program.
- -- This action can be implemented using a library level object which
- -- gets finalized at the end of the main program execution. The above is
- -- a controlled type introduced for this purpose.
+ -- action that takes place at the end of execution of the main program.
+ -- This action is implemented using a library level object which gets
+ -- finalized at the end of program execution. Note that the type should be
+ -- limited, in order to avoid unwanted optimizations.
procedure Finalize (V : in out File_IO_Clean_Up_Type);
-- This is the finalize operation that is used to do the cleanup
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 6bd6e636f7a..3673002c5ef 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -3076,10 +3076,14 @@ package body Sem_Aggr is
-- of all ancestors, starting with the root.
if Nkind (N) = N_Extension_Aggregate then
+
+ -- If the ancestor part is a C++ constructor we must handle
+ -- here that it is a function returning a class-wide type
+
if Is_CPP_Constructor_Call (Ancestor_Part (N)) then
pragma Assert
(Is_Class_Wide_Type (Etype (Ancestor_Part (N))));
- Root_Typ := Base_Type (Etype (Etype (Ancestor_Part (N))));
+ Root_Typ := Root_Type (Etype (Ancestor_Part (N)));
else
Root_Typ := Base_Type (Etype (Ancestor_Part (N)));
end if;
@@ -3462,7 +3466,7 @@ package body Sem_Aggr is
(Inner_Comp, New_Aggr,
Component_Associations (Aggr));
- -- Collect disciminant values and recurse
+ -- Collect discriminant values and recurse
Add_Discriminant_Values
(New_Aggr, Assoc_List);
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 42bbd25a710..1d8e797f1b4 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -5722,14 +5722,25 @@ package body Sem_Ch8 is
if Ekind (Base_Type (T_Name)) = E_Task_Type then
-- In Ada 2005, a task name can be used in an access
- -- definition within its own body.
+ -- definition within its own body. It cannot be used
+ -- in the discriminant part of the task declaration,
+ -- nor anywhere else in the declaration because entries
+ -- cannot have access parameters.
if Ada_Version >= Ada_05
and then Nkind (Parent (N)) = N_Access_Definition
then
Set_Entity (N, T_Name);
Set_Etype (N, T_Name);
- return;
+
+ if Has_Completion (T_Name) then
+ return;
+
+ else
+ Error_Msg_N
+ ("task type cannot be used as type mark " &
+ "within its own declaration", N);
+ end if;
else
Error_Msg_N