From a442bed36cfbfb739244963f22eaf10320a27ec9 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Sun, 8 Nov 2020 16:54:56 -0500 Subject: [PATCH] [Ada] Crash on ghost assignment check for illegal code gcc/ada/ * errout.adb (Error_Msg_NEL): Do not call Set_Posted if errors are being ignored. (Error_Msg): Change Errors_Must_Be_Ignored to use the getter. * sem_ch8.adb (Find_Direct_Name): Do not skip all the error checks when ignoring errors, but instead do not add an entry to the Urefs table if errors are being ignored. * exp_ch5.adb: Minor comment fix. --- gcc/ada/errout.adb | 6 ++++-- gcc/ada/exp_ch5.adb | 2 +- gcc/ada/sem_ch8.adb | 11 ++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index 049db89f24b..fbbf57949ac 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -337,7 +337,7 @@ package body Errout is begin -- Return if all errors are to be ignored - if Errors_Must_Be_Ignored then + if Get_Ignore_Errors then return; end if; @@ -1430,7 +1430,9 @@ package body Errout is Last_Killed := True; end if; - Set_Posted (N); + if not Get_Ignore_Errors then + Set_Posted (N); + end if; end Error_Msg_NEL; ------------------ diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index 93351cf4c85..e720656d847 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -1469,7 +1469,7 @@ package body Exp_Ch5 is -- there are volatile or independent components. If the Prefix of the -- slice is a component or slice, then it might be a part of an object -- with some other volatile or independent components, so we disable the - -- optimization in that case as well. We could complicate this code by + -- optimization in that case as well. We could complicate this code by -- actually looking for such volatile and independent components. if Is_Bit_Packed_Array (L_Type) diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index f78d31a1844..07484d54299 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -5622,7 +5622,10 @@ package body Sem_Ch8 is -- undefined reference. The entry is not added if we are ignoring -- errors. - if not All_Errors_Mode and then Ignore_Errors_Enable = 0 then + if not All_Errors_Mode + and then Ignore_Errors_Enable = 0 + and then not Get_Ignore_Errors + then Urefs.Append ( (Node => N, Err => Emsg, @@ -5752,12 +5755,6 @@ package body Sem_Ch8 is E := Homonym (E); end loop; - -- If we are ignoring errors, skip the error processing - - if Get_Ignore_Errors then - return; - end if; - -- If no entries on homonym chain that were potentially visible, -- and no entities reasonably considered as non-visible, then -- we have a plain undefined reference, with no additional -- 2.30.2