public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-7843] Add missing return in gori_compute::logical_combine
Date: Tue, 26 Sep 2023 19:04:20 +0000 (GMT)	[thread overview]
Message-ID: <20230926190420.63AFF3858C66@sourceware.org> (raw)

https://gcc.gnu.org/g:a612f1bc4d57cebbb47ce858d54a3c5da4c9bfb1

commit r13-7843-ga612f1bc4d57cebbb47ce858d54a3c5da4c9bfb1
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Mon Sep 25 20:48:53 2023 +0200

    Add missing return in gori_compute::logical_combine
    
    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.

Diff:
---
 gcc/gimple-range-gori.cc             |  1 +
 gcc/testsuite/gnat.dg/opt102.adb     | 10 ++++++++++
 gcc/testsuite/gnat.dg/opt102_pkg.adb | 12 ++++++++++++
 gcc/testsuite/gnat.dg/opt102_pkg.ads | 10 ++++++++++
 4 files changed, 33 insertions(+)

diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index d77e1f51ac2..9694e4066e2 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -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
index 00000000000..2b5bec54c3d
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt102.adb
@@ -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
index 00000000000..09c338d0517
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt102_pkg.adb
@@ -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
index 00000000000..7afc3fe6ac7
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt102_pkg.ads
@@ -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;

                 reply	other threads:[~2023-09-26 19:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230926190420.63AFF3858C66@sourceware.org \
    --to=ebotcazou@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).