This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Improve message for condition always False (simple variable case)


The warning message for an always True condition special cased the
simple variable case. This special casing is now extended for the
False case as well:

     1. package CCF_Warn is
     2.    procedure Mess;
     3. end;

     1. package body CCF_Warn is
     2.     type T is array (1..10) of Integer;
     3.     Thing : T := (others => 111);
     4.
     5.     procedure Change (X : integer; Y : out Boolean) is
     6.     begin
     7.         Y := X > 17;
     8.     end Change;
     9.
    10.    procedure Mess is
    11.     Blinking   : Boolean;
    12.     Some_Blink : Boolean;
    13.    begin
    14.
    15.      Blinking := False;
    16.      Some_Blink := False;
    17.
    18.      if Thing (3) = Thing (5) then
    19.         Change (10, Some_Blink);
    20.
    21.         Blinking := Blinking or Some_Blink;
                            |
        >>> warning: object "Blinking" is always False
        >>> warning: (see assignment at line 15)

    22.
    23.      else
    24.         for X in T'range loop
    25.           Thing (X) := -1;
    26.         end loop;
    27.      end if;
    28.    end;
    29. end;

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

2015-01-30  Robert Dewar  <dewar@adacore.com>

	* sem_warn.adb (Warn_On_Known_Condition): Do special casing of
	message for False case.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]