aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2015-05-22 10:52:17 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2015-05-22 10:52:17 +0200
commit6333ad3d459e4734c0cec7eb4e2c89097c9a1466 (patch)
tree2e94024e05c74b0b303ac3cd026f30894f78ab05 /gcc
parent44ae5cd22f30de0a65c3a81ea146a85f07f33013 (diff)
downloadgcc-6333ad3d459e4734c0cec7eb4e2c89097c9a1466.zip
gcc-6333ad3d459e4734c0cec7eb4e2c89097c9a1466.tar.gz
gcc-6333ad3d459e4734c0cec7eb4e2c89097c9a1466.tar.bz2
[multiple changes]
2015-05-21 Robert Dewar <dewar@adacore.com> * exp_util.adb (Activate_Atomic_Synchronization): Do not set Atomic_Sync_Required for an object renaming declaration. * sem_ch8.adb (Analyze_Object_Renaming): Copy Is_Atomic and Is_Independent to renaming object. 2015-05-21 Ed Schonberg <schonberg@adacore.com> * sem_ch5.adb (Analyze_Iterator_Specification): Diagnose various illegalities in iterators over arrays and containers: a) New function Get_Cursor_Type, to verify that the cursor is not a limited type at the point of iteration. b) If the container is a constant, an element_iterator is illegal if the container type does not have a Constant_Indexing aspect. c) If the iterate function has an in-out controlling parameter, the container cannot be a constant object. d) Reject additional cases of iterators over a discriminant-dependent component of a mutable object. From-SVN: r223524
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog20
-rw-r--r--gcc/ada/exp_util.adb7
-rw-r--r--gcc/ada/sem_ch5.adb50
-rw-r--r--gcc/ada/sem_ch8.adb7
4 files changed, 77 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 27492bd..2feb579 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,23 @@
+2015-05-21 Robert Dewar <dewar@adacore.com>
+
+ * exp_util.adb (Activate_Atomic_Synchronization): Do not set
+ Atomic_Sync_Required for an object renaming declaration.
+ * sem_ch8.adb (Analyze_Object_Renaming): Copy Is_Atomic and
+ Is_Independent to renaming object.
+
+2015-05-21 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch5.adb (Analyze_Iterator_Specification): Diagnose
+ various illegalities in iterators over arrays and containers:
+ a) New function Get_Cursor_Type, to verify that the cursor is
+ not a limited type at the point of iteration.
+ b) If the container is a constant, an element_iterator is illegal
+ if the container type does not have a Constant_Indexing aspect.
+ c) If the iterate function has an in-out controlling parameter,
+ the container cannot be a constant object.
+ d) Reject additional cases of iterators over a
+ discriminant-dependent component of a mutable object.
+
2015-05-21 Hristian Kirtchev <kirtchev@adacore.com>
* einfo.adb (Contract): This attribute now applies to constants.
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 5b86d41..d7f9899 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -204,6 +204,13 @@ package body Exp_Util is
when others => null;
end case;
+ -- Nothing to do for the identifier in an object renaming declaration,
+ -- the renaming itself does not need atomic syncrhonization.
+
+ if Nkind (Parent (N)) = N_Object_Renaming_Declaration then
+ return;
+ end if;
+
-- Go ahead and set the flag
Set_Atomic_Sync_Required (N);
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index dcdc7eb..1eb51db 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -2015,10 +2015,11 @@ package body Sem_Ch5 is
-- mutable, to prevent a modification of the container in the
-- course of an iteration.
- if Is_Entity_Name (Iter_Name)
- and then Nkind (Original_Node (Iter_Name)) = N_Selected_Component
+ -- Should comment on need to go to Original_Node ???
+
+ if Nkind (Original_Node (Iter_Name)) = N_Selected_Component
and then Is_Dependent_Component_Of_Mutable_Object
- (Renamed_Object (Entity (Iter_Name)))
+ (Original_Node (Iter_Name))
then
Error_Msg_N
("container cannot be a discriminant-dependent "
@@ -2089,6 +2090,8 @@ package body Sem_Ch5 is
declare
Element : constant Entity_Id :=
Find_Value_Of_Aspect (Typ, Aspect_Iterator_Element);
+ Iterator : constant Entity_Id :=
+ Find_Value_Of_Aspect (Typ, Aspect_Default_Iterator);
Cursor_Type : Entity_Id;
begin
@@ -2120,6 +2123,39 @@ package body Sem_Ch5 is
if Has_Aspect (Typ, Aspect_Variable_Indexing) then
Set_Ekind (Def_Id, E_Variable);
end if;
+
+ -- If the container is a constant, iterating over it
+ -- requires a Constant_Indexing operation.
+
+ if not Is_Variable (Iter_Name)
+ and then not Has_Aspect (Typ, Aspect_Constant_Indexing)
+ then
+ Error_Msg_N ("iteration over constant container "
+ & "require constant_indexing aspect", N);
+
+ -- The Iterate function may have an in_out parameter,
+ -- and a constant container is thus illegal.
+
+ elsif Present (Iterator)
+ and then Ekind (Entity (Iterator)) = E_Function
+ and then Ekind (First_Formal (Entity (Iterator))) /=
+ E_In_Parameter
+ and then not Is_Variable (Iter_Name)
+ then
+ Error_Msg_N
+ ("variable container expected", N);
+ end if;
+
+ if Nkind (Original_Node (Iter_Name))
+ = N_Selected_Component
+ and then
+ Is_Dependent_Component_Of_Mutable_Object
+ (Original_Node (Iter_Name))
+ then
+ Error_Msg_N
+ ("container cannot be a discriminant-dependent "
+ & "component of a mutable object", N);
+ end if;
end if;
end;
end if;
@@ -2168,16 +2204,16 @@ package body Sem_Ch5 is
if Nkind (Iter_Name) = N_Identifier then
declare
- Iter_Kind : constant Node_Kind :=
- Nkind (Original_Node (Iter_Name));
+ Orig_Node : constant Node_Id := Original_Node (Iter_Name);
+ Iter_Kind : constant Node_Kind := Nkind (Orig_Node);
Obj : Node_Id;
begin
if Iter_Kind = N_Selected_Component then
- Obj := Prefix (Original_Node (Iter_Name));
+ Obj := Prefix (Orig_Node);
elsif Iter_Kind = N_Function_Call then
- Obj := First_Actual (Original_Node (Iter_Name));
+ Obj := First_Actual (Orig_Node);
-- If neither, the name comes from source
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 9c564dd..c8c9f1f 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -1344,6 +1344,13 @@ package body Sem_Ch8 is
Set_Is_Volatile (Id, Is_Volatile_Object (Nam));
+ -- Also copy settings of Is_Atomic and Is_Independent
+
+ if Is_Entity_Name (Nam) then
+ Set_Is_Atomic (Id, Is_Atomic (Entity (Nam)));
+ Set_Is_Independent (Id, Is_Independent (Entity (Nam)));
+ end if;
+
-- Treat as volatile if we just set the Volatile flag
if Is_Volatile (Id)