+2018-05-24 Javier Miranda <miranda@adacore.com>
+
+ * sem_ch3.adb (Is_Visible_Component): For untagged types add missing
+ check for renamed discriminants.
+ * sem_ch4.adb (Analyze_Overloaded_Selected_Component,
+ Analyze_Selected_Component, Check_Misspelled_Selector): For calls to
+ Is_Visible_Component pass the associated selector node to allow
+ checking renamed discriminants on untagged types.
+
2018-05-24 Ed Schonberg <schonberg@adacore.com>
* sem_ch8.adb (Analyze_Use_Type): Do not assign the Prev_Use_Clause
-- This test only concerns tagged types
if not Is_Tagged_Type (Original_Type) then
- return True;
+
+ -- Check if this is a renamed discriminant (hidden either by the
+ -- derived type or by some ancestor), unless we are analyzing code
+ -- generated by the expander since it may reference such components
+ -- (for example see the expansion of Deep_Adjust).
+
+ if Ekind (C) = E_Discriminant and then Present (N) then
+ return not Comes_From_Source (N)
+ or else not Is_Completely_Hidden (C);
+ else
+ return True;
+ end if;
-- If it is _Parent or _Tag, there is no visibility issue
Comp := First_Entity (T);
while Present (Comp) loop
if Chars (Comp) = Chars (Sel)
- and then Is_Visible_Component (Comp)
+ and then Is_Visible_Component (Comp, Sel)
then
-- AI05-105: if the context is an object renaming with
Comp := First_Component (Base_Type (Prefix_Type));
while Present (Comp) loop
if Chars (Comp) = Chars (Sel)
- and then Is_Visible_Component (Comp)
+ and then Is_Visible_Component (Comp, Sel)
then
Set_Entity_With_Checks (Sel, Comp);
Generate_Reference (Comp, Sel);
Comp := First_Entity (Prefix);
while Nr_Of_Suggestions <= Max_Suggestions and then Present (Comp) loop
- if Is_Visible_Component (Comp) then
+ if Is_Visible_Component (Comp, Sel) then
if Is_Bad_Spelling_Of (Chars (Comp), Chars (Sel)) then
Nr_Of_Suggestions := Nr_Of_Suggestions + 1;
+2018-05-24 Javier Miranda <miranda@adacore.com>
+
+ * gnat.dg/discr52.adb: New testcase.
+
2018-05-24 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/others1.adb: New testcase.
--- /dev/null
+-- { dg-do compile }
+
+procedure Discr52 is
+ type T_Root (Root_Disc : Natural) is record
+ Data : Natural := 0;
+ end record;
+
+ type T_Derived (deriv_disc : Natural) is
+ new T_Root (root_disc => deriv_disc);
+
+ Derived : T_Derived (Deriv_Disc => 3);
+ Value : Natural;
+
+ procedure Do_Test (Obj : T_Derived) is
+ begin
+ Value := Obj.root_disc; -- { dg-error "no selector \"root_disc\" for type \"T_Derived\" defined at line \\d+" }
+ end;
+begin
+ Do_Test (Derived);
+end;