aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2009-07-10 11:09:59 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2009-07-10 11:09:59 +0200
commitc53265937acc1bc646f5c70ec45676217d07f533 (patch)
treeb0c1ad066b60cf2b06a334ed1befc1564b740d90
parent156f545a1bf194040a24f5e54e1ec5ac4eff642f (diff)
downloadgcc-c53265937acc1bc646f5c70ec45676217d07f533.zip
gcc-c53265937acc1bc646f5c70ec45676217d07f533.tar.gz
gcc-c53265937acc1bc646f5c70ec45676217d07f533.tar.bz2
sem_prag.adb (Analyze pragma, [...]): Analyze argument of pragma, to capture global references if the context is generic.
2009-07-10 Ed Schonberg <schonberg@adacore.com> * sem_prag.adb (Analyze pragma, case Task_Name): Analyze argument of pragma, to capture global references if the context is generic. * exp_ch2.adb (Expand_Discriminant): If a task type discriminant appears within the initialization procedure for the corresponding record, replace it with the proper discriminal. From-SVN: r149459
-rw-r--r--gcc/ada/exp_ch2.adb13
-rw-r--r--gcc/ada/sem_prag.adb6
2 files changed, 16 insertions, 3 deletions
diff --git a/gcc/ada/exp_ch2.adb b/gcc/ada/exp_ch2.adb
index 2963ae8..47b1748 100644
--- a/gcc/ada/exp_ch2.adb
+++ b/gcc/ada/exp_ch2.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
-- --
-- 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- --
@@ -308,6 +308,17 @@ package body Exp_Ch2 is
and then In_Entry
then
Set_Entity (N, CR_Discriminant (Entity (N)));
+
+ -- Finally, if the entity is the discriminant of the original
+ -- type declaration, and we are within the initialization
+ -- procedure for a task, the designated entity is the
+ -- discriminal of the task body. This can happen when the
+ -- argument of pragma Task_Name mentions a discriminant,
+ -- because the pragma is analyzed in the task declaration
+ -- but is expanded in the call to Create_Task in the init_proc.
+
+ elsif Within_Init_Proc then
+ Set_Entity (N, Discriminal (CR_Discriminant (Entity (N))));
else
Set_Entity (N, Discriminal (Entity (N)));
end if;
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 885d1b8..a9ef7d1 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -11248,9 +11248,11 @@ package body Sem_Prag is
Arg := Expression (Arg1);
-- The expression is used in the call to Create_Task, and must be
- -- expanded there, not in the context of the current spec.
+ -- expanded there, not in the context of the current spec. It must
+ -- however be analyzed to capture global references, in case it
+ -- appears in a generic context.
- Preanalyze_And_Resolve (New_Copy_Tree (Arg), Standard_String);
+ Preanalyze_And_Resolve (Arg, Standard_String);
if Nkind (P) /= N_Task_Definition then
Pragma_Misplaced;