aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2015-11-12 11:09:59 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2015-11-12 12:09:59 +0100
commit73f05f9fe869c25fdcaf27f987016736322ca972 (patch)
tree2c7efee59c601ee0513d77097395cce8b0062966
parentb3b5c6a236cf0816e987626120419845c8177eb5 (diff)
downloadgcc-73f05f9fe869c25fdcaf27f987016736322ca972.zip
gcc-73f05f9fe869c25fdcaf27f987016736322ca972.tar.gz
gcc-73f05f9fe869c25fdcaf27f987016736322ca972.tar.bz2
exp_attr.adb (Compile_Stream_Body_In_Scope): When compiling a stream operation for an array type...
2015-11-12 Ed Schonberg <schonberg@adacore.com> * exp_attr.adb (Compile_Stream_Body_In_Scope): When compiling a stream operation for an array type, install the scope of the component type if it is private and not in scope, to prevent spurious errors if the full view of the component type has defaulted discriminants. From-SVN: r230234
-rw-r--r--gcc/ada/ChangeLog8
-rw-r--r--gcc/ada/exp_attr.adb43
2 files changed, 45 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index b8542ee..9a799de 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,11 @@
+2015-11-12 Ed Schonberg <schonberg@adacore.com>
+
+ * exp_attr.adb (Compile_Stream_Body_In_Scope): When compiling
+ a stream operation for an array type, install the scope of the
+ component type if it is private and not in scope, to prevent
+ spurious errors if the full view of the component type has
+ defaulted discriminants.
+
2015-11-12 Eric Botcazou <ebotcazou@adacore.com>
* sem_ch13.adb (Analyze_Attribute_Definition_Clause): For a
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index cb64c39..aaa3c72 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -109,6 +109,16 @@ package body Exp_Attr is
-- If we are within an instance body all visibility has been established
-- already and there is no need to install the package.
+ -- This mechanism is now extended to the component types of the array type,
+ -- when the component type is not in scope and is private, to handle
+ -- properly the case when the full view has defaulted discriminants.
+
+ -- This special processing is ultimately caused by the fact that the
+ -- compiler lacks a well-defined phase when full views are visible
+ -- everywhere. Having such a separate pass would remove much of the
+ -- special-case code that shuffles partial and full views in the middle
+ -- of semantic analysis and expansion.
+
procedure Expand_Access_To_Protected_Op
(N : Node_Id;
Pref : Node_Id;
@@ -624,24 +634,43 @@ package body Exp_Attr is
Arr : Entity_Id;
Check : Boolean)
is
- Installed : Boolean := False;
- Scop : constant Entity_Id := Scope (Arr);
+ C_Type : constant Entity_Id := Base_Type (Component_Type (Arr));
Curr : constant Entity_Id := Current_Scope;
+ Install : Boolean := False;
+ Scop : Entity_Id := Scope (Arr);
+
begin
if Is_Hidden (Arr)
and then not In_Open_Scopes (Scop)
and then Ekind (Scop) = E_Package
+ then
+ Install := True;
+ else
+
+ -- The component type may be private, in which case we install
+ -- its full view to compile the subprogram.
- -- If we are within an instance body, then all visibility has been
- -- established already and there is no need to install the package.
+ Scop := Scope (C_Type);
+ if Is_Private_Type (C_Type)
+ and then Present (Full_View (C_Type))
+ and then not In_Open_Scopes (Scop)
+ and then Ekind (Scop) = E_Package
+ then
+ Install := True;
+ end if;
+ end if;
+
+ -- If we are within an instance body, then all visibility has been
+ -- established already and there is no need to install the package.
+
+ if Install
and then not In_Instance_Body
then
Push_Scope (Scop);
Install_Visible_Declarations (Scop);
Install_Private_Declarations (Scop);
- Installed := True;
-- The entities in the package are now visible, but the generated
-- stream entity must appear in the current scope (usually an
@@ -649,6 +678,8 @@ package body Exp_Attr is
-- scopes.
Push_Scope (Curr);
+ else
+ Install := False;
end if;
if Check then
@@ -657,7 +688,7 @@ package body Exp_Attr is
Insert_Action (N, Decl, Suppress => All_Checks);
end if;
- if Installed then
+ if Install then
-- Remove extra copy of current scope, and package itself