This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
This patch diagnoses properly ambiguous procedure calls written in prefixed
notation, when the prefix is itself an overloaded function call.
Compiling test1.adb must yield:
test1.adb:11:26: ambiguous call to "Get"
test1.adb:11:26: interpretation (inherited) at objs.ads:23
test1.adb:11:26: interpretation at objs.ads:27
test1.adb:11:30: ambiguous expression (cannot resolve "Op")
test1.adb:11:30: possible interpretation at objs.ads:6
test1.adb:11:30: possible interpretation at objs.ads:21
---
with Objs;
procedure Test1 is
My_Base_Ptr_Wrapper : Objs.p1.Base_Ptr_Wrapper;
My_Derived_Ptr_Wrapper : Objs.p2.Derived_Ptr_Wrapper;
begin
My_Base_Ptr_Wrapper.Base_Obj_Ptr := new Objs.p2.Derived_Obj;
My_Derived_Ptr_Wrapper.Base_Obj_Ptr := new Objs.p2.Derived_Obj;
My_Derived_Ptr_Wrapper.Derived_Obj_Ptr := new Objs.p2.Derived_Obj;
My_Derived_Ptr_Wrapper.Get.Op; -- (2) -- Ambiguous
end;
---
package Objs is
package p1 is
type Base_Obj is tagged null record;
type Base_Obj_Class_Access is access all Base_Obj'Class;
procedure Op (Self : in Base_Obj);
type Base_Ptr_Wrapper is tagged record
Base_Obj_Ptr : Base_Obj_Class_Access;
end record;
function Get (Self : in Base_Ptr_Wrapper) return access Base_Obj'Class;
end p1;
package p2 is
type Derived_Obj is new p1.Base_Obj with null record;
type Derived_Obj_Class_Access is access all Derived_Obj'Class;
overriding
procedure Op (Self : in Derived_Obj);
type Derived_Ptr_Wrapper is new p1.Base_Ptr_Wrapper with record
Derived_Obj_Ptr : Derived_Obj_Class_Access;
end record;
function Get
(Self : in Derived_Ptr_Wrapper) return access Derived_Obj'Class;
end p2;
end;
Tested on x86_64-pc-linux-gnu, committed on trunk
2010-06-14 Ed Schonberg <schonberg@adacore.com>
* sem_ch4.adb (Analyze_One_Call): If the call has been rewritten from a
prefixed form, do not re-analyze first actual, which may need an
implicit dereference.
* sem_ch6.adb (Analyze_Procedure_Call): If the call is given in
prefixed notation, the analysis will rewrite the node, and possible
errors appear in the rewritten name of the node.
* sem_res.adb: If a call is ambiguous because its first parameter is
an overloaded call, report list of candidates, to clarify ambiguity of
enclosing call.
Attachment:
difs
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |