The varying case currently falls through to the 1/true case.
gcc/
* gimple-range-gori.cc (gori_compute::logical_combine): Add missing
return statement in the varying case.
gcc/testsuite/
* gnat.dg/opt102.adb:New test.
* gnat.dg/opt102_pkg.adb, gnat.dg/opt102_pkg.ads: New helper.
r.dump (dump_file);
fputc ('\n', dump_file);
}
+ return res;
}
switch (code)
--- /dev/null
+-- { dg-do run }
+-- { dg-options "-O2 -gnata" }
+
+with Opt102_Pkg; use Opt102_Pkg;
+
+procedure Opt102 is
+ I, F : aliased Integer;
+begin
+ I := Get (Two, F'Access, null);
+end;
--- /dev/null
+package body Opt102_Pkg is
+
+ function Get (E : Enum; F, M : access Integer) return Integer is
+ begin
+ case E is
+ when One => return 0;
+ when Two => return F.all;
+ when Three => return M.all;
+ end case;
+ end;
+
+end Opt102_Pkg;
--- /dev/null
+package Opt102_Pkg is
+
+ type Enum is (One, Two, Three);
+
+ function Get (E : Enum; F, M : access Integer) return Integer
+ with Pre => (E = One) = (F = null and M = null) and
+ (E = Two) = (F /= null) and
+ (E = Three) = (M /= null);
+
+end Opt102_Pkg;