[Ada] Wrong dispatching call in type with aspect Implicit_Dereference

Programming / Compilers / GCC - pmderodat [138bc75d-0d04-0410-961f-82ee72b054a4] - 13 August 2019 08:08 EDT

When a record type with an an access to class-wide type discriminant has aspect Implicit_Dereference, and the discriminant is used as the controlling argument of a dispatching call, the compiler may generate wrong code to dispatch the call.

2019-08-13 Javier Miranda

gcc/ada/

- sem_res.adb (Resolve_Selected_Component): When the type of the component is an access to a class-wide type and the type of the context is an access to a tagged type the relevant type is that of the component (since in such case we may need to generate implicit type conversions or dispatching calls).

gcc/testsuite/

- gnat.dg/tagged3.adb, gnat.dg/tagged3_pkg.adb, gnat.dg/tagged3_pkg.ads: New testcase.

e2cbc30501e [Ada] Wrong dispatching call in type with aspect Implicit_Dereference
gcc/ada/ChangeLog | 8 +++++++
gcc/ada/sem_res.adb | 15 +++++++++++++
gcc/testsuite/ChangeLog | 5 +++++
gcc/testsuite/gnat.dg/tagged3.adb | 42 +++++++++++++++++++++++++++++++++++
gcc/testsuite/gnat.dg/tagged3_pkg.adb | 12 ++++++++++
gcc/testsuite/gnat.dg/tagged3_pkg.ads | 9 ++++++++
6 files changed, 91 insertions(+)

Upstream: gcc.gnu.org


  • Share