C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration)
This switch is deprecated; use -Werror=implicit-function-declaration instead.
+Wexceptions
+C++ ObjC++ Var(warn_exceptions) Init(1)
+Warn when an exception handler is shadowed by another handler.
+
Wextra
C ObjC C++ ObjC++ Warning
; in common.opt
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;
}
}
-Wctor-dtor-privacy -Wno-delete-incomplete @gol
-Wdelete-non-virtual-dtor -Wdeprecated-copy -Wdeprecated-copy-dtor @gol
-Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion @gol
--Weffc++ -Wextra-semi -Wno-inaccessible-base @gol
+-Weffc++ -Wno-exceptions -Wextra-semi -Wno-inaccessible-base @gol
-Wno-inherited-variadic-ctor -Wno-init-list-lifetime @gol
-Wno-invalid-offsetof -Wno-literal-suffix -Wmismatched-tags @gol
-Wmultiple-inheritance -Wnamespaces -Wnarrowing @gol
headers do not obey all of these guidelines; use @samp{grep -v}
to filter out those warnings.
+@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
+@opindex Wexceptions
+@opindex Wno-exceptions
+Disable the warning about the case when an exception handler is shadowed by
+another handler, which can point out a wrong ordering of exception handlers.
+
@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
@opindex Wstrict-null-sentinel
@opindex Wno-strict-null-sentinel
--- /dev/null
+// PR c++/97675
+
+struct Base { };
+struct Child : Base { };
+int main() {
+ try { throw Child(); }
+ catch (Base const&) { }
+ catch (Child const&) { } // { dg-warning "exception of type .Child. will be caught by earlier handler" }
+}
--- /dev/null
+// PR c++/97675
+// { dg-additional-options -Wno-exceptions }
+
+struct Base { };
+struct Child : Base { };
+int main() {
+ try { throw Child(); }
+ catch (Base const&) { }
+ catch (Child const&) { } // { dg-bogus "exception of type .Child. will be caught by earlier handler" }
+}
catch (A*) { }
try { f(); }
- catch (A*) { } // { dg-warning "" } A* before B*
- catch (B*) { } // { dg-warning "" } A* before B*
+ catch (A*) { } // { dg-message "for type" } A* before B*
+ catch (B*) { } // { dg-warning "will be caught" } A* before B*
try { f(); }
catch (A*) { }