aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/except.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-11-03 17:46:23 -0500
committerMarek Polacek <polacek@redhat.com>2020-11-05 15:57:22 -0500
commit1d87302a8e20c1f49dd37177ec869ee94abc11a5 (patch)
treef4ba979a14c37961427d82e77686667be8cb8be1 /gcc/cp/except.c
parent5b2003105b35f8fe8e074c055a718c8f484d9d32 (diff)
downloadgcc-1d87302a8e20c1f49dd37177ec869ee94abc11a5.zip
gcc-1d87302a8e20c1f49dd37177ec869ee94abc11a5.tar.gz
gcc-1d87302a8e20c1f49dd37177ec869ee94abc11a5.tar.bz2
c++: Add -Wexceptions warning option [PR97675]
This PR asks that we add a warning option for an existing (very old) warning, so that it can be disabled selectively. clang++ uses -Wexceptions for this, so I added this new option rather than using e.g. -Wnoexcept. gcc/c-family/ChangeLog: PR c++/97675 * c.opt (Wexceptions): New option. gcc/cp/ChangeLog: PR c++/97675 * except.c (check_handlers_1): Use OPT_Wexceptions for the warning. Use inform for the second part of the warning. gcc/ChangeLog: PR c++/97675 * doc/invoke.texi: Document -Wexceptions. gcc/testsuite/ChangeLog: PR c++/97675 * g++.old-deja/g++.eh/catch10.C: Adjust dg-warning. * g++.dg/warn/Wexceptions1.C: New test. * g++.dg/warn/Wexceptions2.C: New test.
Diffstat (limited to 'gcc/cp/except.c')
-rw-r--r--gcc/cp/except.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index cb1a410..985206f 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -975,11 +975,10 @@ check_handlers_1 (tree master, tree_stmt_iterator i)
tree handler = tsi_stmt (i);
if (TREE_TYPE (handler) && can_convert_eh (type, TREE_TYPE (handler)))
{
- warning_at (EXPR_LOCATION (handler), 0,
- "exception of type %qT will be caught",
- TREE_TYPE (handler));
- warning_at (EXPR_LOCATION (master), 0,
- " by earlier handler for %qT", type);
+ if (warning_at (EXPR_LOCATION (handler), OPT_Wexceptions,
+ "exception of type %qT will be caught by earlier "
+ "handler", TREE_TYPE (handler)))
+ inform (EXPR_LOCATION (master), "for type %qT", type);
break;
}
}