From: squirek Date: Tue, 14 Jan 2025 06:40:08 +0000 (+0000) Subject: ada: Spurious accessibility error with -gnatc X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b56a782224d90205710311a3623769a5d8befe28;p=thirdparty%2Fgcc.git ada: Spurious accessibility error with -gnatc The patch fixes an issue in the compiler whereby a spurious accessibility error gets generated in semantic checking mode (-gnatc) when an explicitly aliased formal gets used as an actual for an access disriminant in a return object. gcc/ada/ChangeLog: * accessibility.adb (Check_Return_Construct_Accessibility): Disable check generation when we are only checking semantics. --- diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb index 8c85173aa34..200f892a96f 100644 --- a/gcc/ada/accessibility.adb +++ b/gcc/ada/accessibility.adb @@ -1642,6 +1642,13 @@ package body Accessibility is (No (Extra_Accessibility_Of_Result (Scope_Id)) and then Is_Formal_Of_Current_Function (Assoc_Expr) and then Is_Tagged_Type (Etype (Scope_Id))) + + -- Disable the check generation when we are only checking semantics + -- since required locals do not get generated (e.g. extra + -- accessibility of result), and constant folding can occur and + -- lead to spurious errors. + + and then Operating_Mode /= Check_Semantics then -- Generate a dynamic check based on the extra accessibility of -- the result or the scope of the current function.