From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 050B83989007; Wed, 16 Jun 2021 08:44:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 050B83989007 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1498] [Ada] Reorder code for validity checks of unchecked conversions X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: 331170392082ccfb782a6edb263fc2a32d058c70 X-Git-Newrev: c50041b99bc621cc1e2c7b7dbb67c0600926072e Message-Id: <20210616084412.050B83989007@sourceware.org> Date: Wed, 16 Jun 2021 08:44:12 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2021 08:44:12 -0000 https://gcc.gnu.org/g:c50041b99bc621cc1e2c7b7dbb67c0600926072e commit r12-1498-gc50041b99bc621cc1e2c7b7dbb67c0600926072e Author: Piotr Trojanek Date: Wed Feb 17 23:32:25 2021 +0100 [Ada] Reorder code for validity checks of unchecked conversions gcc/ada/ * sem_ch13.adb (Validate_Unchecked_Conversion): Move detection of generic types before switching to their private views; fix style in using AND THEN. Diff: --- gcc/ada/sem_ch13.adb | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index a9770db6b61..8aa62c89deb 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -16578,18 +16578,7 @@ package body Sem_Ch13 is -- here because the processing for generic instantiation always makes -- subtypes, and we want the original frozen actual types. - -- If we are dealing with private types, then do the check on their - -- fully declared counterparts if the full declarations have been - -- encountered (they don't have to be visible, but they must exist). - Source := Ancestor_Subtype (Etype (First_Formal (Act_Unit))); - - if Is_Private_Type (Source) - and then Present (Underlying_Type (Source)) - then - Source := Underlying_Type (Source); - end if; - Target := Ancestor_Subtype (Etype (Act_Unit)); -- If either type is generic, the instantiation happens within a generic @@ -16600,6 +16589,16 @@ package body Sem_Ch13 is return; end if; + -- If we are dealing with private types, then do the check on their + -- fully declared counterparts if the full declarations have been + -- encountered (they don't have to be visible, but they must exist). + + if Is_Private_Type (Source) + and then Present (Underlying_Type (Source)) + then + Source := Underlying_Type (Source); + end if; + if Is_Private_Type (Target) and then Present (Underlying_Type (Target)) then @@ -16692,8 +16691,8 @@ package body Sem_Ch13 is -- in the same unit as the unchecked conversion, then set the flag -- No_Strict_Aliasing (no strict aliasing is implicit here) - if Is_Access_Type (Target) and then - In_Same_Source_Unit (Target, N) + if Is_Access_Type (Target) + and then In_Same_Source_Unit (Target, N) then Set_No_Strict_Aliasing (Implementation_Base_Type (Target)); end if;