public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/81660] Add -Wexceptions warning
       [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
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: egallager at gcc dot gnu.org @ 2020-11-05 21:42 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=97675
                 CC|                            |egallager at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
Marek submitted a patch for a -Wexceptions here:
https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558173.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/81660] Add -Wexceptions warning
       [not found] <bug-81660-4@http.gcc.gnu.org/bugzilla/>
  2020-11-05 21:42 ` [Bug c++/81660] Add -Wexceptions warning 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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-05 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yup, that was only an option for the existing warning.  We should extend the
warning to detect the case above too.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/81660] Add -Wexceptions warning
       [not found] <bug-81660-4@http.gcc.gnu.org/bugzilla/>
  2020-11-05 21:42 ` [Bug c++/81660] Add -Wexceptions warning 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
  2020-11-06 15:26 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-06  2:01 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/81660] Add -Wexceptions warning
       [not found] <bug-81660-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-11-06  2:01 ` mpolacek at gcc dot gnu.org
@ 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
  5 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-06 15:26 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/81660] Add -Wexceptions warning
       [not found] <bug-81660-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-11-06 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:43d3b7bc073df27800218b685e6d7dd78dd31905

commit r11-4803-g43d3b7bc073df27800218b685e6d7dd78dd31905
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Nov 5 21:46:06 2020 -0500

    c++: Small tweak to can_convert_eh [PR81660]

    While messing with check_handlers_1, I spotted this bug report which
    complains that we don't warn about the case when we have two duplicated
    handlers of type int.  can_convert_eh implements [except.handle] and
    that says: A handler is a match for an exception object of type E if
     - The handler is of type cv T or cv T& and E and T are the same type
       (ignoring the top-level cv-qualifiers), or [...]

    but we don't implement this bullet properly for non-class types.  The
    fix therefore seems pretty obvious.  Also change the return type to
    bool when we're only returning yes/no.

    gcc/cp/ChangeLog:

            PR c++/81660
            * except.c (can_convert_eh): Change the return type to bool.  If
            the type TO and FROM are the same, return true.

    gcc/testsuite/ChangeLog:

            PR c++/81660
            * g++.dg/warn/Wexceptions3.C: New test.
            * g++.dg/eh/pr42859.C: Add dg-warning.
            * g++.dg/torture/pr81659.C: Likewise.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/81660] Add -Wexceptions warning
       [not found] <bug-81660-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2020-11-06 21:41 ` cvs-commit at gcc dot gnu.org
@ 2020-11-06 21:42 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-11-06 21:42 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Done in GCC 11.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-06 21:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-81660-4@http.gcc.gnu.org/bugzilla/>
2020-11-05 21:42 ` [Bug c++/81660] Add -Wexceptions warning 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
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

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).