summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch5.adb
diff options
context:
space:
mode:
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-08 03:20:30 +0000
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-08 03:20:30 +0000
commit643df0593c630691fa6877cddeefdd4c3023d444 (patch)
tree1eb48ad31d05a9ce117bedc17115de96dffa2f0b /gcc/ada/sem_ch5.adb
parent54f3f029d816c6d1626310649adfda740e203f7b (diff)
parentd5d8f1ccc6d3972dc5cfc0949e85e0b1c9e24ee0 (diff)
downloadgcc-transactional-memory.tar.gz
* Merge from mainline rev 181122.transactional-memory
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/transactional-memory@181148 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_ch5.adb')
-rw-r--r--gcc/ada/sem_ch5.adb26
1 files changed, 20 insertions, 6 deletions
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index 1b0f919d3ff..0e6c5cf98bd 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -2429,8 +2429,17 @@ package body Sem_Ch5 is
-- The type of the loop variable is the Iterator_Element aspect of
-- the container type.
- Set_Etype (Def_Id,
- Entity (Find_Aspect (Typ, Aspect_Iterator_Element)));
+ declare
+ Element : constant Entity_Id :=
+ Find_Aspect (Typ, Aspect_Iterator_Element);
+ begin
+ if No (Element) then
+ Error_Msg_NE ("cannot iterate over&", N, Typ);
+ return;
+ else
+ Set_Etype (Def_Id, Entity (Element));
+ end if;
+ end;
else
-- For an iteration of the form IN, the name must denote an
@@ -2440,12 +2449,17 @@ package body Sem_Ch5 is
if Is_Entity_Name (Original_Node (Name (N)))
and then not Is_Iterator (Typ)
then
- Error_Msg_N
- ("name must be an iterator, not a container", Name (N));
+ if No (Find_Aspect (Typ, Aspect_Iterator_Element)) then
+ Error_Msg_NE
+ ("cannot iterate over&", Name (N), Typ);
+ else
+ Error_Msg_N
+ ("name must be an iterator, not a container", Name (N));
+ end if;
Error_Msg_NE
- ("\to iterate directly over a container, write `of &`",
- Name (N), Original_Node (Name (N)));
+ ("\to iterate directly over the elements of a container, " &
+ "write `of &`", Name (N), Original_Node (Name (N)));
end if;
-- The result type of Iterate function is the classwide type of