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