Hi Arnaud, this is a great feature. How does it handle unchecked unions? Will it warn if you write to a field but only read the value via a different field?
Ciao, Duncan.
GNAT did not issue a warning when assigning to a part of an object, and not referencing the object later on. Now it does so in some cases, similarly to the existing warnings on assignment to elementary objects. On the code below, GNAT now issues warnings: $ gcc -c -gnatwa assign.adb assign.adb:8:05: warning: useless assignment to "X", value never referenced assign.adb:9:04: warning: useless assignment to "Y", value never referenced --- procedure Assign is type T is record U : Integer; end record; X : T := T'(U => 0); Y : array (1..2) of Integer := (others => 0); begin X.U := X.U + 1; Y (2) := Y (1); end Assign; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-04 Yannick Moy<m...@adacore.com> * checks.adb (Apply_Float_Conversion_Check): correct a typo where Lo_OK was used instead of Hi_OK, which could cause a read of an uninitialized value later on. Detected while working on the new warning. * exp_ch9.adb (Expand_N_Entry_Declaration): remove useless assignment to local variable. * sem_ch5.adb (Analyze_Assignment): set the last assignment component in more cases, in order to detect more unreferenced values. * sem_util.adb, sem_util.ads (Get_Enclosing_Object): return enclosing object for expression, if any.