+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
-- 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;
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
-- scopes.
Push_Scope (Curr);
+ else
+ Install := False;
end if;
if Check then
Insert_Action (N, Decl, Suppress => All_Checks);
end if;
- if Installed then
+ if Install then
-- Remove extra copy of current scope, and package itself