From 6109adeb7d392421306416182d2cf3241b7ba3ac Mon Sep 17 00:00:00 2001 From: Robert Dewar Date: Tue, 31 Oct 2006 19:06:22 +0100 Subject: [PATCH] sem_ch11.adb (Analyze_Handled_Statements): Move final test for useless assignments here and conditionalize it on absence... 2006-10-31 Robert Dewar * sem_ch11.adb (Analyze_Handled_Statements): Move final test for useless assignments here and conditionalize it on absence of exception handlers. (Analyze_Exception_Handlers): Small code reorganization of error detection code, for new handling of formal packages. From-SVN: r118299 --- gcc/ada/sem_ch11.adb | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/gcc/ada/sem_ch11.adb b/gcc/ada/sem_ch11.adb index 978c7e38e96..75ee081a16d 100644 --- a/gcc/ada/sem_ch11.adb +++ b/gcc/ada/sem_ch11.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -41,6 +41,7 @@ with Sem_Ch5; use Sem_Ch5; with Sem_Ch8; use Sem_Ch8; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; +with Sem_Warn; use Sem_Warn; with Sinfo; use Sinfo; with Stand; use Stand; with Uintp; use Uintp; @@ -271,13 +272,7 @@ package body Sem_Ch11 is while Scop /= Standard_Standard and then Ekind (Scop) = E_Package loop - -- If the exception is declared in an inner - -- instance, nothing else to check. - - if Is_Generic_Instance (Scop) then - exit; - - elsif Nkind (Declaration_Node (Scop)) = + if Nkind (Declaration_Node (Scop)) = N_Package_Specification and then Nkind (Original_Node (Parent @@ -291,6 +286,12 @@ package body Sem_Ch11 is ("\and therefore cannot appear in " & "handler ('R'M 11.2(8))", Id); exit; + + -- If the exception is declared in an inner + -- instance, nothing else to check. + + elsif Is_Generic_Instance (Scop) then + exit; end if; Scop := Scope (Scop); @@ -347,11 +348,23 @@ package body Sem_Ch11 is Kill_All_Checks; end if; + -- Analyze statements in sequence + Analyze_Statements (Statements (N)); + -- If the current scope is a subprogram, and there are no explicit + -- exception handlers, then this is the right place to check for + -- hanging useless assignments from the statement sequence of the + -- subprogram body. + + if Is_Subprogram (Current_Scope) then + Warn_On_Useless_Assignments (Current_Scope); + end if; + + -- Deal with handlers or AT END proc + if Present (Handlers) then Analyze_Exception_Handlers (Handlers); - elsif Present (At_End_Proc (N)) then Analyze (At_End_Proc (N)); end if; -- 2.30.2