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] Redundant comparison to True


This patch corrects the placement of an error message concerning a redundant
comparison to True. The patch also add machinery to explain the nature of the
redundant True.

------------
-- Source --
------------

--  main.adb

procedure Main is
   type Rec (Discr : Boolean) is null record;

   function Self (Flag : Boolean) return Boolean is
   begin
      return Flag;
   end Self;

   Obj : constant Rec := Rec'(Discr => True);

begin
   if Self (True) = Obj.Discr then
      null;
   end if;

end Main;

----------------------------
-- Compilation and output --
----------------------------

$ gcc -c -gnatwa main.adb
main.adb:12:19: warning: comparison with True is redundant
main.adb:12:25: warning: discriminant "Discr" is always True

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

2013-04-24  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_res.adb (Explain_Redundancy): New routine.
	(Resolve_Equality_Op): Place the error concerning a redundant
	comparison to True at the "=". Try to explain the nature of the
	redundant True.

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]