]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add missing return in gori_compute::logical_combine
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 25 Sep 2023 18:48:53 +0000 (20:48 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Tue, 26 Sep 2023 19:04:11 +0000 (21:04 +0200)
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.

gcc/gimple-range-gori.cc
gcc/testsuite/gnat.dg/opt102.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt102_pkg.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt102_pkg.ads [new file with mode: 0644]

index d77e1f51ac20a5347e70b92b632fa1847b2cc483..9694e4066e2c4457fa2b3bf0cd320411280396c3 100644 (file)
@@ -835,6 +835,7 @@ gori_compute::logical_combine (vrange &r, enum tree_code code,
          r.dump (dump_file);
          fputc ('\n', dump_file);
        }
+      return res;
     }
 
   switch (code)
diff --git a/gcc/testsuite/gnat.dg/opt102.adb b/gcc/testsuite/gnat.dg/opt102.adb
new file mode 100644 (file)
index 0000000..2b5bec5
--- /dev/null
@@ -0,0 +1,10 @@
+-- { 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;
diff --git a/gcc/testsuite/gnat.dg/opt102_pkg.adb b/gcc/testsuite/gnat.dg/opt102_pkg.adb
new file mode 100644 (file)
index 0000000..09c338d
--- /dev/null
@@ -0,0 +1,12 @@
+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;
diff --git a/gcc/testsuite/gnat.dg/opt102_pkg.ads b/gcc/testsuite/gnat.dg/opt102_pkg.ads
new file mode 100644 (file)
index 0000000..7afc3fe
--- /dev/null
@@ -0,0 +1,10 @@
+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;