// Explicit { dg-require-effective-target exceptions_enabled } to avoid verify compiler messages FAILs for '-fno-exceptions'. // { dg-options "-Wcatch-value=1" } struct A { virtual ~A() {} }; struct B : A {}; struct C {}; struct D : C {}; void foo() { try {} catch (D) {} catch (C) {} catch (B) {} // { dg-warning "10:catching polymorphic type" } catch (A) {} // { dg-warning "10:catching polymorphic type" } catch (A*) {} catch (int) {} try {} catch (D&) {} catch (C&) {} catch (B&) {} catch (A&) {} catch (A*) {} catch (int&) {} } template void foo1() { try {} catch (T) {} // { dg-warning "10:catching polymorphic type" } } template void foo2() { try {} catch (T*) {} try {} catch (T&) {} try {} catch (const T&) {} } void bar() { foo1(); foo1(); foo1(); foo1(); foo1(); foo1(); foo1(); // { dg-message "required" } foo1(); // { dg-message "required" } foo1(); foo1(); foo2(); foo2(); foo2(); foo2(); foo2(); }