[Ada] Remove duplicated condition in warnings about read-before-write

Message ID 20211202162842.GA2157432@adacore.com
State Committed
Commit e2e877266de127fbcd6f14e85e0c46ce4731c207
Headers
Series [Ada] Remove duplicated condition in warnings about read-before-write |

Commit Message

Pierre-Marie de Rodat Dec. 2, 2021, 4:28 p.m. UTC
  Code for warnings about read-before-write of a variable had one
condition in the outer IF statement and then the very same condition in
an inner IF statement.

Cleanup related to spurious warning on 'Initialized.

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

gcc/ada/

	* sem_warn.adb (Check_References): Remove redundant condition.
  

Patch

diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -1569,15 +1569,13 @@  package body Sem_Warn is
                         --  For access types, UR was only set for dereferences,
                         --  so the issue is that the value may be null.
 
-                        if not Is_Trivial_Subprogram (Scope (E1)) then
-                           if not Warnings_Off_E1 then
-                              if Is_Access_Type (Etype (Parent (UR))) then
-                                 Error_Msg_N ("??`&.&` may be null!", UR);
-                              else
-                                 Error_Msg_N
-                                   ("??`&.&` may be referenced before "
-                                    & "it has a value!", UR);
-                              end if;
+                        if not Warnings_Off_E1 then
+                           if Is_Access_Type (Etype (Parent (UR))) then
+                              Error_Msg_N ("??`&.&` may be null!", UR);
+                           else
+                              Error_Msg_N
+                                ("??`&.&` may be referenced before "
+                                 & "it has a value!", UR);
                            end if;
                         end if;