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 r11-8507] Remove call to gcc_unreachable in range-op.cc
Date: Thu,  3 Jun 2021 10:49:35 +0000 (GMT)	[thread overview]
Message-ID: <20210603104935.D3A2D383D000@sourceware.org> (raw)

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

commit r11-8507-gd4ffc1d11b6193d4b65ee3fa7d9156bb1cb72090
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Mon May 10 17:41:01 2021 +0200

    Remove call to gcc_unreachable in range-op.cc
    
    The Ada testcase happens to stumble on the call to gcc_unreachable in
    operator_bitwise_xor::op1_range, but there is nothing wrong going on
    and it's safe to let it go through.
    
    gcc/
            * range-op.cc (get_bool_state): Adjust head comment.
            (operator_not_equal::op1_range): Fix comment.
            (operator_bitwise_xor::op1_range): Remove call to gcc_unreachable.
    gcc/testsuite/
            * gnat.dg/specs/opt5.ads: New test.
            * gnat.dg/specs/opt5_pkg.ads: New helper.

Diff:
---
 gcc/range-op.cc                          | 11 +++++------
 gcc/testsuite/gnat.dg/specs/opt5.ads     | 25 +++++++++++++++++++++++++
 gcc/testsuite/gnat.dg/specs/opt5_pkg.ads | 17 +++++++++++++++++
 3 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 0027b3e1427..3a35a2fb25b 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -358,10 +358,8 @@ range_true_and_false (tree type)
 
 enum bool_range_state { BRS_FALSE, BRS_TRUE, BRS_EMPTY, BRS_FULL };
 
-// Return the summary information about boolean range LHS.  Return an
-// "interesting" range in R.  For EMPTY or FULL, return the equivalent
-// range for TYPE, for BRS_TRUE and BRS false, return the negation of
-// the bool range.
+// Return the summary information about boolean range LHS.  If EMPTY/FULL,
+// return the equivalent range for TYPE in R; if FALSE/TRUE, do nothing.
 
 static bool_range_state
 get_bool_state (irange &r, const irange &lhs, tree val_type)
@@ -383,6 +381,7 @@ get_bool_state (irange &r, const irange &lhs, tree val_type)
       r.set_varying (val_type);
       return BRS_FULL;
     }
+
   return BRS_TRUE;
 }
 
@@ -538,7 +537,7 @@ operator_not_equal::op1_range (irange &r, tree type,
       break;
 
     case BRS_FALSE:
-      // If its true, the result is the same as OP2.
+      // If it's false, the result is the same as OP2.
       r = op2;
       break;
 
@@ -2643,7 +2642,7 @@ operator_bitwise_xor::op1_range (irange &r, tree type,
 	  r = op2;
 	  break;
 	default:
-	  gcc_unreachable ();
+	  break;
 	}
       return true;
     }
diff --git a/gcc/testsuite/gnat.dg/specs/opt5.ads b/gcc/testsuite/gnat.dg/specs/opt5.ads
new file mode 100644
index 00000000000..09b8db54c56
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/opt5.ads
@@ -0,0 +1,25 @@
+-- { dg-do compile }
+-- { dg-options "-O2 -gnata -gnatVa" }
+
+with Opt5_Pkg;
+
+package Opt5 is
+
+  type Object is new Opt5_Pkg.Object with private;
+
+  Undefined : constant Object;
+
+  overriding function Is_Defined (Self : Object) return Boolean;
+
+  function Create (Sloc : Opt5_Pkg.Object) return Integer is (0)
+    with Pre  => Sloc.Is_Defined;
+
+private
+
+  type Object is new Opt5_Pkg.Object with null record;
+
+  Undefined : constant Object := (Opt5_Pkg.Undefined with others => <>);
+
+  overriding function Is_Defined (Self : Object) return Boolean is (Self /= Undefined);
+
+end Opt5;
diff --git a/gcc/testsuite/gnat.dg/specs/opt5_pkg.ads b/gcc/testsuite/gnat.dg/specs/opt5_pkg.ads
new file mode 100644
index 00000000000..a549f08a723
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/opt5_pkg.ads
@@ -0,0 +1,17 @@
+package Opt5_Pkg is
+
+  type Object is tagged private;
+
+  Undefined : constant Object;
+
+  function Is_Defined (Self : Object) return Boolean;
+
+private
+
+  type Object is tagged null record;
+
+  Undefined : constant Object := (others => <>);
+
+  function Is_Defined (Self : Object) return Boolean is (Self /= Undefined);
+
+end Opt5_Pkg;


                 reply	other threads:[~2021-06-03 10:49 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=20210603104935.D3A2D383D000@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).