This patches fixes a bug in which a function returns an anonymous access
type whose designated type is a class-wide interface type, and the
return statement returns a raise expression, the compiler crashes.

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-09-07  Bob Duff  <d...@adacore.com>

        * sem_ch6.adb (Analyze_Function_Return): Do not
        insert an explicit conversion to force the displacement of the
        "this" pointer to reference the secondary dispatch table in the
        case where the return statement is returning a raise expression,
        as in "return raise ...".

Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb (revision 251835)
+++ sem_ch6.adb (working copy)
@@ -910,7 +910,7 @@
             if Expander_Active
               and then Serious_Errors_Detected = 0
               and then Is_Access_Type (R_Type)
-              and then Nkind (Expr) /= N_Null
+              and then not Nkind_In (Expr, N_Null, N_Raise_Expression)
               and then Is_Interface (Designated_Type (R_Type))
               and then Is_Progenitor (Designated_Type (R_Type),
                                       Designated_Type (Etype (Expr)))

Reply via email to