+2018-01-11 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch6.adb (Freeze_Expr_Types): If an access value is the
+ controlling argument of a dispatching call. freeze the corresponding
+ designated type.
+
2018-01-11 Ben Brosgol <brosgol@adacore.com>
* doc/Makefile: Add Sphinx option -W to treat warnings as errors.
Check_And_Freeze_Type (Designated_Type (Etype (Node)));
end if;
+ -- An implicit dereference freezes the designated type. In the
+ -- case of a dispatching call whose controlling argument is an
+ -- access type, the dereference is not made explicit, so we must
+ -- check for such a call and freeze the designated type.
+
+ if Nkind (Node) in N_Has_Etype
+ and then Present (Etype (Node))
+ and then Is_Access_Type (Etype (Node))
+ and then Nkind (Parent (Node)) = N_Function_Call
+ and then Node = Controlling_Argument (Parent (Node))
+ then
+ Check_And_Freeze_Type (Designated_Type (Etype (Node)));
+ end if;
+
-- No point in posting several errors on the same expression
if Serious_Errors_Detected > 0 then
+2018-01-11 Ed Schonberg <schonberg@adacore.com>
+
+ * gnat.dg/expr_func3.adb, gnat.dg/expr_func3.ads: New testcase.
+
2018-01-11 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/fixedpnt2.adb, gnat.dg/fixedpnt2.ads: New testcase.
--- /dev/null
+-- { dg-do compile }
+
+package body Expr_Func3 is
+
+ procedure Dummy is null;
+
+end Expr_Func3;
--- /dev/null
+package Expr_Func3 is
+
+ type Obj_T is abstract tagged null record;
+
+ type T is access all Obj_T'Class;
+
+ function Slave (Obj : access Obj_T) return T is (T(Obj));
+
+ function Optional_Slave (Obj : T) return T;
+
+ procedure Dummy;
+
+private
+
+ function Optional_Slave (Obj : T) return T is
+ (if Obj = null then null else Slave (Obj));
+
+end Expr_Func3;