* [Ada] Fix spurious loop warning for function with Out parameter
@ 2019-07-22 14:02 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2019-07-22 14:02 UTC (permalink / raw)
To: gcc-patches; +Cc: Eric Botcazou
[-- Attachment #1: Type: text/plain, Size: 550 bytes --]
The compiler gives a spurious warning about a possible infinite while
loop whose condition contains a call to a function that takes an Out or
In/Out parameter and whose actual is a variable that is not modified in
the loop, because it still thinks that functions can only have In
parameters.
Tested on x86_64-pc-linux-gnu, committed on trunk
2019-07-22 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* sem_warn.adb (Find_Var): Bail out for a function call with an
Out or In/Out parameter.
gcc/testsuite/
* gnat.dg/warn23.adb: New testcase.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 780 bytes --]
--- gcc/ada/sem_warn.adb
+++ gcc/ada/sem_warn.adb
@@ -333,6 +333,11 @@ package body Sem_Warn is
elsif Has_Warnings_Off (Entity (Name (N))) then
return;
+
+ -- Forget it if the parameter is not In
+
+ elsif Has_Out_Or_In_Out_Parameter (Entity (Name (N))) then
+ return;
end if;
-- OK, see if we have one argument
--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/warn23.adb
@@ -0,0 +1,17 @@
+-- { dg-do compile }
+
+procedure Warn23 is
+
+ type Enum_Type is (A, B, C);
+
+ function Poll (E : out Enum_Type) return Boolean
+ with Convention => Ada,
+ Import => True;
+
+ E : Enum_Type;
+
+begin
+ while Poll (E) loop
+ null;
+ end loop;
+end;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-07-22 14:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-22 14:02 [Ada] Fix spurious loop warning for function with Out parameter Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).