then
null;
+ -- Don't replace the discriminant in strict preanalysis mode since
+ -- it can lead to errors during full analysis when the discriminant
+ -- gets referenced later.
+
+ -- This can occur in situations where a protected type contains
+ -- an expression function which references a discriminant.
+
+ elsif Preanalysis_Active
+ and then Inside_Preanalysis_Without_Freezing = 0
+ then
+ null;
+
else
Set_Entity (N, Discriminal (E));
end if;
if Is_Type (Entity (N)) then
Set_Etype (N, Entity (N));
- -- The exception to this general rule are constants associated with
- -- discriminals of protected types because for each protected op
- -- a new set of discriminals is internally created by the frontend
- -- (see Exp_Ch9.Set_Discriminals), and the current decoration of the
- -- entity pointer may have been set as part of a preanalysis, where
- -- discriminals still reference the first subprogram or entry to be
- -- expanded (see Expand_Protected_Body_Declarations).
-
- elsif Full_Analysis
- and then Ekind (Entity (N)) = E_Constant
- and then Present (Discriminal_Link (Entity (N)))
- and then Is_Protected_Type (Scope (Discriminal_Link (Entity (N))))
- then
- goto Find_Name;
-
else
declare
Entyp : constant Entity_Id := Etype (Entity (N));
return;
end if;
- <<Find_Name>>
-
-- Preserve relevant elaboration-related attributes of the context which
-- are no longer available or very expensive to recompute once analysis,
-- resolution, and expansion are over.