public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/81660] Add -Wexceptions warning
Date: Fri, 06 Nov 2020 02:01:48 +0000	[thread overview]
Message-ID: <bug-81660-4-Ip4CSHTwXy@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-81660-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81660

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Candidate patch:

--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -41,7 +41,6 @@ static tree do_allocate_exception (tree);
 static tree wrap_cleanups_r (tree *, int *, void *);
 static int complete_ptr_ref_or_void_ptr_p (tree, tree);
 static bool is_admissible_throw_operand_or_catch_parameter (tree, bool);
-static int can_convert_eh (tree, tree);

 /* Sets up all the global eh stuff that needs to be initialized at the
    start of compilation.  */
@@ -932,31 +931,34 @@ nothrow_libfn_p (const_tree fn)
 /* Returns nonzero if an exception of type FROM will be caught by a
    handler for type TO, as per [except.handle].  */

-static int
+static bool
 can_convert_eh (tree to, tree from)
 {
   to = non_reference (to);
   from = non_reference (from);

+  if (same_type_ignoring_top_level_qualifiers_p (to, from))
+    return true;
+
   if (TYPE_PTR_P (to) && TYPE_PTR_P (from))
     {
       to = TREE_TYPE (to);
       from = TREE_TYPE (from);

       if (! at_least_as_qualified_p (to, from))
-   return 0;
+   return false;

       if (VOID_TYPE_P (to))
-   return 1;
+   return true;

       /* Else fall through.  */
     }

   if (CLASS_TYPE_P (to) && CLASS_TYPE_P (from)
       && publicly_uniquely_derived_p (to, from))
-    return 1;
+    return true;

-  return 0;
+  return false;
 }

 /* Check whether any of the handlers in I are shadowed by another handler

  parent reply	other threads:[~2020-11-06  2:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-81660-4@http.gcc.gnu.org/bugzilla/>
2020-11-05 21:42 ` egallager at gcc dot gnu.org
2020-11-05 21:46 ` mpolacek at gcc dot gnu.org
2020-11-06  2:01 ` mpolacek at gcc dot gnu.org [this message]
2020-11-06 15:26 ` mpolacek at gcc dot gnu.org
2020-11-06 21:41 ` cvs-commit at gcc dot gnu.org
2020-11-06 21:42 ` mpolacek at gcc dot gnu.org

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=bug-81660-4-Ip4CSHTwXy@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).