summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2010-06-14 08:14:10 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2010-06-14 10:14:10 +0200
commit438ff97c274020cf44c92a47593ebceffa6c06cf (patch)
treef17524d1633d55b13a0f7439b81e0e068aa18d48
parent71158d7e6d3ce21ac0ef3b96a516073870178631 (diff)
downloadgcc-438ff97c274020cf44c92a47593ebceffa6c06cf.tar.gz
sem_ch4.adb (Complete_Object_Operation): After analyzing the rewritten call...
2010-06-14 Ed Schonberg <schonberg@adacore.com> * sem_ch4.adb (Complete_Object_Operation): After analyzing the rewritten call, preserve the resulting type to prevent spurious errors, when the call is implicitly dereferenced in the context of an in-out actual. * checks.adb (Apply_Discriminant_Check): If the target of the assignment is a renaming of a heap object, create constrained type for it to apply check. From-SVN: r160709
-rw-r--r--gcc/ada/ChangeLog11
-rw-r--r--gcc/ada/checks.adb24
-rw-r--r--gcc/ada/sem_ch4.adb11
3 files changed, 44 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index fb03eadd7cc..b7660b50808 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,14 @@
+2010-06-14 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch4.adb (Complete_Object_Operation): After analyzing the
+ rewritten call, preserve the resulting type to prevent spurious errors,
+ when the call is implicitly dereferenced in the context of an in-out
+ actual.
+
+ * checks.adb (Apply_Discriminant_Check): If the target of the
+ assignment is a renaming of a heap object, create constrained type for
+ it to apply check.
+
2010-06-14 Pascal Obry <obry@adacore.com>
* prj-proc.adb: Fix copy of object directory for extending projects.
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index ff511665b73..29689d16637 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -1084,6 +1084,11 @@ package body Checks is
Cond : Node_Id;
T_Typ : Entity_Id;
+ function Denotes_Explicit_Dereference (Obj : Node_Id) return Boolean;
+ -- A heap object with an indefinite subtype is constrained by its
+ -- initial value, and assigning to it requires a constraint_check.
+ -- The target may be an explicit dereference, or a renaming of one.
+
function Is_Aliased_Unconstrained_Component return Boolean;
-- It is possible for an aliased component to have a nominal
-- unconstrained subtype (through instantiation). If this is a
@@ -1091,6 +1096,21 @@ package body Checks is
-- in an initialization, the check must be suppressed. This unusual
-- situation requires a predicate of its own.
+ ----------------------------------
+ -- Denotes_Explicit_Dereference --
+ ----------------------------------
+
+ function Denotes_Explicit_Dereference (Obj : Node_Id) return Boolean is
+ begin
+ return
+ Nkind (Obj) = N_Explicit_Dereference
+ or else
+ (Is_Entity_Name (Obj)
+ and then Present (Renamed_Object (Entity (Obj)))
+ and then Nkind (Renamed_Object (Entity (Obj)))
+ = N_Explicit_Dereference);
+ end Denotes_Explicit_Dereference;
+
----------------------------------------
-- Is_Aliased_Unconstrained_Component --
----------------------------------------
@@ -1164,7 +1184,7 @@ package body Checks is
-- Ada 2005 (AI-363): For Ada 2005, we limit the building of the actual
-- subtype to the parameter and dereference cases, since other aliased
-- objects are unconstrained (unless the nominal subtype is explicitly
- -- constrained). (But we also need to test for renamings???)
+ -- constrained).
if Present (Lhs)
and then (Present (Param_Entity (Lhs))
@@ -1174,7 +1194,7 @@ package body Checks is
and then not Is_Aliased_Unconstrained_Component)
or else (Ada_Version >= Ada_05
and then not Is_Constrained (T_Typ)
- and then Nkind (Lhs) = N_Explicit_Dereference
+ and then Denotes_Explicit_Dereference (Lhs)
and then Nkind (Original_Node (Lhs)) /=
N_Function_Call))
then
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 899b1a05878..c29b783f5ea 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -6182,6 +6182,17 @@ package body Sem_Ch4 is
Save_Interps (Subprog, Node_To_Replace);
else
Analyze (Node_To_Replace);
+
+ -- If the operation has been rewritten into a call, which may
+ -- get subsequently an explicit dereference, preserve the
+ -- type on the original node (selected component or indexed
+ -- component) for subsequent legality tests, e.g. Is_Variable.
+ -- which examines the original node.
+
+ if Nkind (Node_To_Replace) = N_Function_Call then
+ Set_Etype
+ (Original_Node (Node_To_Replace), Etype (Node_To_Replace));
+ end if;
end if;
end Complete_Object_Operation;