+2016-12-08 Jakub Jelinek <jakub@redhat.com>
+
+ P0003R5 - removal of dynamic exception specification from C++17
+ * parser.c (cp_parser_exception_specification_opt): For C++17
+ error out on throw ( type-id-list ), for C++11 and C++14 issue
+ -Wdeprecated warning on it. Formatting fix. Treat throw()
+ in C++17 as noexcept(true).
+
2016-12-07 Martin Jambor <mjambor@suse.cz>
PR c++/78589
token = cp_lexer_peek_token (parser->lexer);
/* Is it a noexcept-specification? */
- type_id_list = cp_parser_noexcept_specification_opt(parser, true, NULL,
- false);
+ type_id_list = cp_parser_noexcept_specification_opt (parser, true, NULL,
+ false);
if (type_id_list != NULL_TREE)
return type_id_list;
if (!cp_parser_is_keyword (token, RID_THROW))
return NULL_TREE;
-#if 0
- /* Enable this once a lot of code has transitioned to noexcept? */
- if (cxx_dialect >= cxx11 && !in_system_header_at (input_location))
- warning (OPT_Wdeprecated, "dynamic exception specifications are "
- "deprecated in C++0x; use %<noexcept%> instead");
-#endif
+ location_t loc = token->location;
/* Consume the `throw'. */
cp_lexer_consume_token (parser->lexer);
type_id_list = cp_parser_type_id_list (parser);
/* Restore the saved message. */
parser->type_definition_forbidden_message = saved_message;
+
+ if (cxx_dialect >= cxx1z)
+ {
+ error_at (loc, "ISO C++1z does not allow dynamic exception "
+ "specifications");
+ type_id_list = NULL_TREE;
+ }
+ else if (cxx_dialect >= cxx11 && !in_system_header_at (loc))
+ warning_at (loc, OPT_Wdeprecated,
+ "dynamic exception specifications are deprecated in C++11;"
+ " use %<noexcept%> instead");
}
+ /* In C++17, throw() is equivalent to noexcept (true). throw()
+ is deprecated in C++11 and above as well, but is still widely used,
+ so don't warn about it yet. */
+ else if (cxx_dialect >= cxx1z)
+ type_id_list = noexcept_true_spec;
else
type_id_list = empty_except_spec;
+2016-12-08 Jakub Jelinek <jakub@redhat.com>
+
+ P0003R5 - removal of dynamic exception specification from C++17
+ * g++.dg/compat/eh/ctor1.h: Adjust for deprecation of
+ throw (type-id-list) in C++11 and C++14 and removal in C++17.
+ * g++.dg/compat/eh/ctor1_y.C: Likewise.
+ * g++.dg/compat/eh/new1_x.C: Likewise.
+ * g++.dg/compat/eh/new1_y.C: Likewise.
+ * g++.dg/compat/eh/spec3_x.C: Likewise.
+ * g++.dg/compat/eh/spec3_y.C: Likewise.
+ * g++.dg/compat/eh/template1.h: Likewise.
+ * g++.dg/compat/eh/template1_y.C: Likewise.
+ * g++.dg/compat/eh/unexpected1_x.C: Likewise.
+ * g++.dg/compat/eh/unexpected1_y.C: Likewise.
+ * g++.dg/cpp0x/auto9.C: Likewise.
+ * g++.dg/cpp0x/defaulted23.C: Likewise.
+ * g++.dg/cpp0x/error5.C: Likewise.
+ * g++.dg/cpp0x/lambda/lambda-eh2.C: Likewise.
+ * g++.dg/cpp0x/noexcept02.C: Likewise.
+ * g++.dg/cpp0x/noexcept07.C: Likewise.
+ * g++.dg/cpp0x/noexcept08.C: Likewise.
+ * g++.dg/cpp0x/noexcept19.C: Likewise.
+ * g++.dg/cpp0x/variadic73.C: Likewise.
+ * g++.dg/cpp0x/variadic-throw.C: Likewise.
+ * g++.dg/cpp1z/noexcept-type1.C: Likewise.
+ * g++.dg/eh/async-unwind2.C: Likewise.
+ * g++.dg/eh/cond4.C: Likewise.
+ * g++.dg/eh/delete1.C: Likewise.
+ * g++.dg/eh/ehopt1.C: Likewise.
+ * g++.dg/eh/forced3.C: Likewise.
+ * g++.dg/eh/forced4.C: Likewise.
+ * g++.dg/eh/init-temp2.C: Likewise.
+ * g++.dg/eh/pr38662.C: Likewise.
+ * g++.dg/eh/pr41819.C: Likewise.
+ * g++.dg/eh/shadow1.C: Likewise.
+ * g++.dg/eh/spec2.C: Likewise.
+ * g++.dg/eh/spec3.C: Likewise.
+ * g++.dg/eh/spec5.C: Likewise.
+ * g++.dg/eh/spec6.C: Likewise.
+ * g++.dg/eh/spec7.C: Likewise.
+ * g++.dg/eh/spec8.C: Likewise.
+ * g++.dg/eh/spec9.C: Likewise.
+ * g++.dg/eh/template1.C: Likewise.
+ * g++.dg/eh/unexpected1.C: Likewise.
+ * g++.dg/ext/has_nothrow_assign.C: Likewise.
+ * g++.dg/ext/has_nothrow_constructor.C: Likewise.
+ * g++.dg/ext/has_nothrow_copy-1.C: Likewise.
+ * g++.dg/ext/has_nothrow_copy-2.C: Likewise.
+ * g++.dg/ext/has_nothrow_copy-4.C: Likewise.
+ * g++.dg/ext/has_nothrow_copy-5.C: Likewise.
+ * g++.dg/ext/has_nothrow_copy-6.C: Likewise.
+ * g++.dg/ext/has_nothrow_copy-7.C: Likewise.
+ * g++.dg/gcov/gcov-7.C: Likewise.
+ * g++.dg/init/new13.C: Likewise.
+ * g++.dg/init/new25.C: Likewise.
+ * g++.dg/lookup/exception1.C: Likewise.
+ * g++.dg/opt/noreturn-1.C: Likewise.
+ * g++.dg/other/error3.C: Likewise.
+ * g++.dg/rtti/crash3.C: Likewise.
+ * g++.dg/template/eh2.C: Likewise.
+ * g++.dg/template/error36.C: Likewise.
+ * g++.dg/tm/pr46567.C: Likewise.
+ * g++.dg/tm/pr47340.C: Likewise.
+ * g++.dg/torture/pr46364.C: Likewise.
+ * g++.dg/torture/pr49394.C: Likewise.
+ * g++.dg/torture/pr52918-1.C: Likewise.
+ * g++.dg/torture/pr57190.C: Likewise.
+ * g++.dg/torture/stackalign/eh-alloca-1.C: Likewise.
+ * g++.dg/torture/stackalign/eh-fastcall-1.C: Likewise.
+ * g++.dg/torture/stackalign/eh-global-1.C: Likewise.
+ * g++.dg/torture/stackalign/eh-inline-1.C: Likewise.
+ * g++.dg/torture/stackalign/eh-inline-2.C: Likewise.
+ * g++.dg/torture/stackalign/eh-thiscall-1.C: Likewise.
+ * g++.dg/torture/stackalign/eh-vararg-1.C: Likewise.
+ * g++.dg/torture/stackalign/eh-vararg-2.C: Likewise.
+ * g++.dg/tree-ssa/pr45605.C: Likewise.
+ * g++.dg/warn/Wreturn-type-3.C: Likewise.
+ * g++.old-deja/g++.eh/badalloc1.C: Likewise.
+ * g++.old-deja/g++.eh/cleanup2.C: Likewise.
+ * g++.old-deja/g++.eh/spec1.C: Likewise.
+ * g++.old-deja/g++.eh/spec2.C: Likewise.
+ * g++.old-deja/g++.eh/spec3.C: Likewise.
+ * g++.old-deja/g++.eh/spec4.C: Likewise.
+ * g++.old-deja/g++.eh/spec6.C: Likewise.
+ * g++.old-deja/g++.eh/throw1.C: Likewise.
+ * g++.old-deja/g++.eh/throw2.C: Likewise.
+ * g++.old-deja/g++.eh/tmpl1.C: Likewise.
+ * g++.old-deja/g++.eh/tmpl3.C: Likewise.
+ * g++.old-deja/g++.mike/eh15.C: Likewise.
+ * g++.old-deja/g++.mike/eh25.C: Likewise.
+ * g++.old-deja/g++.mike/eh33.C: Likewise.
+ * g++.old-deja/g++.mike/eh34.C: Likewise.
+ * g++.old-deja/g++.mike/eh50.C: Likewise.
+ * g++.old-deja/g++.mike/eh51.C: Likewise.
+ * g++.old-deja/g++.mike/eh55.C: Likewise.
+ * g++.old-deja/g++.mike/p10416.C: Likewise.
+ * g++.old-deja/g++.other/crash28.C: Likewise.
+ * g++.old-deja/g++.other/crash30.C: Likewise.
+ * g++.old-deja/g++.other/new7.C: Likewise.
+ * g++.old-deja/g++.pt/ehspec1.C: Likewise.
+ * g++.old-deja/g++.robertl/eb123.C: Likewise.
+
2016-12-08 Naveen H.S <Naveen.Hurugalawadi@cavium.com>
- * gcc.target/aarch64/pr78382.c : New Testcase.
+ * gcc.target/aarch64/pr78382.c: New testcase.
2016-12-08 Andrew Pinski <apinski@cavium.com>
- * gcc.target/aarch64/pr71112.c : New Testcase.
+ * gcc.target/aarch64/pr71112.c: New testcase.
2016-12-07 Martin Sebor <msebor@redhat.com>
PR middle-end/77784
PR middle-end/78149
PR middle-end/78138
-
* c-c++-common/Wsizeof-pointer-memaccess2.c: Adjust expected diagnostic.
* g++.dg/ext/builtin-object-size3.C (bar): Same.
* g++.dg/ext/strncpy-chk1.C: Same.
2016-12-07 Naveen H.S <Naveen.Hurugalawadi@cavium.com>
- * gcc.target/aarch64/pr71727.c : New Testcase.
+ * gcc.target/aarch64/pr71727.c: New testcase.
2016-12-06 Tom de Vries <tom@codesourcery.com>
2016-11-23 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
- * gcc.target/aarch64/ldp_stp_1.c : Add -mcpu=generic.
- * gcc.target/aarch64/store-pair-1.c : Likewise.
+ * gcc.target/aarch64/ldp_stp_1.c: Add -mcpu=generic.
+ * gcc.target/aarch64/store-pair-1.c: Likewise.
2016-11-23 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
- * gcc.target/aarch64/fmaxmin.c : Add -fno-vect-cost-model.
- * gcc.target/aarch64/fmul_fcvt_2.c : Likewise.
- * gcc.target/aarch64/vect-abs-compile.c : Likewise.
- * gcc.target/aarch64/vect-clz.c : Likewise.
- * gcc.target/aarch64/vect-fcm-eq-d.c : Likewise.
- * gcc.target/aarch64/vect-fcm-ge-d.c : Likewise.
- * gcc.target/aarch64/vect-fcm-gt-d.c : Likewise.
- * gcc.target/aarch64/vect-fmovd-zero.c : Likewise.
- * gcc.target/aarch64/vect-fmovd.c : Likewise.
- * gcc.target/aarch64/vect-fmovf-zero.c : Likewise.
- * gcc.target/aarch64/vect-fmovf.c : Likewise.
- * gcc.target/aarch64/vect_ctz_1.c : Likewise.
+ * gcc.target/aarch64/fmaxmin.c: Add -fno-vect-cost-model.
+ * gcc.target/aarch64/fmul_fcvt_2.c: Likewise.
+ * gcc.target/aarch64/vect-abs-compile.c: Likewise.
+ * gcc.target/aarch64/vect-clz.c: Likewise.
+ * gcc.target/aarch64/vect-fcm-eq-d.c: Likewise.
+ * gcc.target/aarch64/vect-fcm-ge-d.c: Likewise.
+ * gcc.target/aarch64/vect-fcm-gt-d.c: Likewise.
+ * gcc.target/aarch64/vect-fmovd-zero.c: Likewise.
+ * gcc.target/aarch64/vect-fmovd.c: Likewise.
+ * gcc.target/aarch64/vect-fmovf-zero.c: Likewise.
+ * gcc.target/aarch64/vect-fmovf.c: Likewise.
+ * gcc.target/aarch64/vect_ctz_1.c: Likewise.
2016-11-23 Peter Bergner <bergner@vnet.ibm.com>
2016-07-28 Paul Thomas <pault@gcc.gnu.org>
PR fortran/71883
- * gfortran.dg/pr71883.f90 : New test.
+ * gfortran.dg/pr71883.f90: New test.
2016-07-28 Yuri Rumyantsev <ysrumyan@gmail.com>
2016-02-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/69423
- * gfortran.dg/deferred_character_15.f90 : New test.
+ * gfortran.dg/deferred_character_15.f90: New test.
2016-02-20 Dominique d'Humieres <dominiq@lps.ens.fr>
struct Bar
{
- ~Bar () throw(int);
+ ~Bar ()
+#if __cplusplus < 201103L
+ throw(int)
+#else
+ noexcept(false)
+#endif
+ ;
Foo f;
};
was_f_in_Bar_destroyed=true;
}
-Bar::~Bar() throw(int)
+Bar::~Bar()
+#if __cplusplus < 201103L
+throw(int)
+#else
+noexcept(false)
+#endif
{
throw 1;
}
extern "C" void exit (int);
extern "C" void abort (void);
-extern void * operator new[] (std::size_t s) throw (std::bad_alloc);
+extern void * operator new[] (std::size_t s)
+#if __cplusplus < 201103L
+throw (std::bad_alloc)
+#endif
+;
extern void operator delete[] (void *p) throw ();
struct A
extern int ret;
void *ptr;
-void * operator new[] (std::size_t s) throw (std::bad_alloc)
+void * operator new[] (std::size_t s)
+#if __cplusplus < 201103L
+throw (std::bad_alloc)
+#endif
{
ptr = operator new (s);
return ptr;
#include "spec3.h"
-extern void func () throw (B,A);
+extern void func ()
+#if __cplusplus < 201103L
+throw (B,A)
+#endif
+;
void spec3_x (void)
{
A::A() {}
-void func() throw (B,A)
+void func()
+#if __cplusplus < 201103L
+throw (B,A)
+#endif
{
throw A();
}
{
typedef B<T> D;
typedef typename D::E E;
- void f() throw(E);
+ void f()
+#if __cplusplus < 201103L
+ throw(E)
+#endif
+ ;
};
#include "template1.h"
-template<class T> void C<T>::f (void) throw (E)
+template<class T> void C<T>::f (void)
+#if __cplusplus < 201103L
+throw (E)
+#endif
{
throw E();
}
+// { dg-options "-std=c++98" }
+
#include <exception>
struct One { };
+// { dg-options "-std=c++98" }
+
struct One { };
struct Two { };
void
badthrow () throw (auto) // { dg-error "invalid use of" }
-{
-}
+{ // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+} // { dg-warning "deprecated" "" { target { ! c++1z } } .-2 }
void
badthrow2 () throw (auto &) // { dg-error "invalid use of|expected" }
-{
-}
+{ // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+} // { dg-warning "deprecated" "" { target { ! c++1z } } .-2 }
template <auto V = 4> struct G {}; // { dg-error "auto" "" { target { ! c++1z } } }
struct B
{
- B() throw (int) = default; // { dg-message "exception-specification" }
-};
-
-B b; // { dg-error "deleted" }
+ B() throw (int) = default; // { dg-message "exception-specification" "" { target { ! c++1z } } }
+}; // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { ! c++1z } } .-2 }
+B b; // { dg-error "deleted" "" { target { ! c++1z } } }
struct C
{
- C() throw (int) { }
-};
+ C() throw (int) { } // { dg-error "dynamic exception specification" "" { target c++1z } }
+}; // { dg-warning "deprecated" "" { target { ! c++1z } } .-1 }
C c;
struct D: C
{
- D() throw (int) = default;
-};
+ D() throw (int) = default; // { dg-error "dynamic exception specification" "" { target c++1z } }
+}; // { dg-warning "deprecated" "" { target { ! c++1z } } .-1 }
D d;
struct bad_alloc { };
}
-void* operator new(std::size_t) throw (std::bad_alloc);
+void* operator new(std::size_t)
+#if __cplusplus <= 201402L
+throw (std::bad_alloc) // { dg-warning "deprecated" "" { target { ! c++1z } } }
+#endif
+;
namespace std
{
// PR c++/47263
// PR c++/49260
// { dg-options "-fno-asynchronous-unwind-tables -fno-dwarf2-cfi-asm" }
-// { dg-do run { target c++11 } }
+// { dg-do run { target { c++11 && { ! c++1z } } } }
#include <exception>
std::set_unexpected( []{ throw 0; } );
try
{
- []() throw( int ) { throw nullptr; }();
+ []() throw( int ) { throw nullptr; }(); // { dg-warning "deprecated" }
}
catch( int )
{ }
SA(!noexcept(f()));
-void g() throw (int); // { dg-message "previous declaration" }
-void g() noexcept(false); // { dg-error "different exception" }
+void g() throw (int); // { dg-message "previous declaration" "" { target { ! c++1z } } }
+ // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { ! c++1z } } .-2 }
+void g() noexcept(false); // { dg-error "different exception" "" { target { ! c++1z } } }
void g();
void h() throw();
// Test that checking of a nothrow specification uses the one on the
-// definition.
-// { dg-do run { target c++11 } }
+// definition. In C++17 throw() is equivalent to noexcept(true).
+// { dg-do run { target { c++11 && c++14_down } } }
#include <exception>
#include <cstdlib>
virtual void g() throw();
virtual void h() noexcept;
virtual void i() noexcept(false);
- virtual void j() throw(int);
-};
+ virtual void j() throw(int); // { dg-error "dynamic exception specification" "" { target c++1z } }
+}; // { dg-warning "deprecated" "" { target { ! c++1z } } .-1 }
struct B: A
{
void g() noexcept(false); // { dg-error "looser" }
void h() noexcept(false); // { dg-error "looser" }
void i() noexcept(false);
- void j() noexcept(false); // { dg-error "looser" }
+ void j() noexcept(false); // { dg-error "looser" "" { target { ! c++1z } } }
};
struct E: A
{
- void f() throw(int);
+ void f() throw(int); // { dg-error "dynamic exception specification" "" { target c++1z } }
+ // { dg-warning "deprecated" "" { target { ! c++1z } } .-1 }
void g() throw(int); // { dg-error "looser" }
+ // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { ! c++1z } } .-2 }
void h() throw(int); // { dg-error "looser" }
- void i() throw(int);
- void j() throw(int);
+ // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { ! c++1z } } .-2 }
+ void i() throw(int); // { dg-error "dynamic exception specification" "" { target c++1z } }
+ // { dg-warning "deprecated" "" { target { ! c++1z } } .-1 }
+ void j() throw(int); // { dg-error "dynamic exception specification" "" { target c++1z } }
+ // { dg-warning "deprecated" "" { target { ! c++1z } } .-1 }
};
struct F: A
void g(); // { dg-error "looser" }
void h(); // { dg-error "looser" }
void i();
- void j(); // { dg-error "looser" }
+ void j(); // { dg-error "looser" "" { target { ! c++1z } } }
};
struct D
{
- D () throw (int);
+ D ()
+#if __cplusplus <= 201402L
+ throw (int) // { dg-warning "deprecated" "" { target { ! c++1z } } }
+#endif
+ ;
};
C <D, B <D>> c;
template<int... M> struct S
{
- template<int... N> static int foo() throw (pair <M, N>...) // { dg-error "mismatched" }
- {
- return 1;
+ template<int... N> static int foo() throw (pair <M, N>...) // { dg-error "mismatched" "" { target { ! c++1z } } }
+ { // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ return 1; // { dg-warning "deprecated" "" { target { ! c++1z } } .-2 }
}
};
int wibble()
{
- return S<0, 1, 2>::foo<0, 1> (); // { dg-error "no matching" }
+ return S<0, 1, 2>::foo<0, 1> (); // { dg-error "no matching" "" { target { ! c++1z } } }
}
struct B {};
struct C {};
-template<typename... Exceptions> void f(int idx) throw(Exceptions...) {
+template<typename... Exceptions> void f(int idx)
+#if __cplusplus <= 201402L
+throw(Exceptions...) // { dg-warning "deprecated" "" { target { ! c++1z } } }
+#endif
+{
if (idx == 0) throw A();
else if (idx == 1) throw B();
else if (idx == 2) throw C();
// Testcase from P0012r1
// { dg-options -std=c++1z }
-void (*p)() throw(int);
+void (*p)() throw(int); // { dg-error "dynamic exception specification" }
void (**pp)() noexcept = &p; // { dg-error "" } cannot convert to pointer to noexcept function
struct S { typedef void (*p)(); operator p(); };
struct Z;
-X <V> baz1 (const S &) throw (E);
-X <Z> baz2 (const X <Z> &) throw (E);
+X <V> baz1 (const S &)
+#if __cplusplus <= 201402L
+throw (E) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+;
+X <Z> baz2 (const X <Z> &)
+#if __cplusplus <= 201402L
+throw (E) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+;
template <typename T> X<T>::X ()
{
return &y;
}
-X <V> baz1 (const S &) throw (E)
+X <V> baz1 (const S &)
+#if __cplusplus <= 201402L
+throw (E) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
return X<V> ();
}
{
}
-X <Z> baz2 (const X <Z> &) throw (E)
+X <Z> baz2 (const X <Z> &)
+#if __cplusplus <= 201402L
+throw (E) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
throw E ();
}
struct A {
A(int) { }
- ~A() throw(int) { throw 1; };
+ ~A()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#else
+ noexcept(false)
+#endif
+ { throw 1; };
};
struct B {
B(A) { }
}
struct Foo {
- ~Foo() throw(int) {throw 1;}
+ ~Foo()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#else
+ noexcept(false)
+#endif
+ {throw 1;}
};
struct Baz {
{
deleted = 2;
}
- virtual ~Baz() throw(int) {throw 1;}
+ virtual ~Baz()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#else
+ noexcept(false)
+#endif
+ {throw 1;}
};
int non_virt ()
public:
A(int) { ++count; if (b) throw 1; }
A(const A&) { ++count; if (b) throw 1; }
- ~A() throw(int) { --count; if (b) throw 1; }
+ ~A()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#else
+ noexcept(false)
+#endif
+ { --count; if (b) throw 1; }
};
typedef A<int, int> B;
public:
A() { if (b) throw 1; }
A(const B&) { if (b) throw 1; }
- ~A() throw(int) { if (b) throw 1; }
+ ~A()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#else
+ noexcept(false)
+#endif
+ { if (b) throw 1; }
};
typedef A<void *, void *> C;
// HP-UX libunwind.so doesn't provide _UA_END_OF_STACK.
// { dg-do run { xfail "ia64-hp-hpux11.*" } }
+// { dg-require-effective-target c++14_down }
// Test that forced unwinding calls std::unexpected going
// through a nothrow function.
}
static void
-doit () throw(int)
+doit ()
+#if __cplusplus <= 201402L
+throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
force_unwind ();
}
public:
explicit AutoPtr(_Tp* __p = 0) : _M_ptr(__p) {}
- ~AutoPtr() throw(int) { delete _M_ptr; }
+ ~AutoPtr()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#else
+ noexcept(false)
+#endif
+ { delete _M_ptr; }
};
struct A
{
A() { }
- ~A() throw(int) { throw 1; }
+ ~A()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#else
+ noexcept(false)
+#endif
+ { throw 1; }
};
struct B
{
- virtual ~B() throw(int);
+ virtual ~B()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#else
+ noexcept(false)
+#endif
+ ;
};
B* f (const A &s) { throw 1; }
class E { };
class T {
- int foo(bool a) throw (E) __attribute__((regparm(1)));
+ int foo(bool a)
+#if __cplusplus <= 201402L
+ throw (E) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ __attribute__((regparm(1)));
int bar(bool b) __attribute__((regparm(1)));
};
try {} catch (...) {} // { dg-error "" }
}
-void f2() throw(int)
+void f2()
+#if __cplusplus <= 201402L
+throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
bar();
}
friend class E;
static B *baz (D *);
- virtual void V () throw (B); // { dg-error "overriding" "" }
-};
-
+ virtual void V () throw (B); // { dg-error "overriding" "" { target { ! c++1z } } }
+}; // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-2 }
struct E : public D
{
- virtual void V () throw (D); // { dg-error "looser throw" "" }
-};
-
+ virtual void V () throw (D); // { dg-error "looser throw" "" { target { ! c++1z } } }
+}; // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-2 }
B* foo (D *);
B *D::baz (D *p)
struct S { void f (void); };
typedef void f1 (void) throw (int); // { dg-error "exception" "" { target c++14_down } }
+ // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-2 }
typedef void (*f2) (void) throw (int); // { dg-error "exception" "" { target c++14_down } }
+ // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-2 }
typedef void (S::*f3) (void) throw (int); // { dg-error "exception" "" { target c++14_down } }
-
-void (*f4) (void) throw (int);
-void (S::*f5) (void) throw (int);
+ // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-2 }
+void (*f4) (void) throw (int); // { dg-error "dynamic exception specification" "" { target c++1z } }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-1 }
+void (S::*f5) (void) throw (int); // { dg-error "dynamic exception specification" "" { target c++1z } }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-1 }
struct B {};
-void func() throw (B,A)
+void func()
+#if __cplusplus <= 201402L
+throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
throw A();
}
struct B
{
- void f () throw (A);
+ void f ()
+#if __cplusplus <= 201402L
+ throw (A)
+#endif
+ ;
};
struct A {};
-void B::f () throw (A) {}
+void B::f ()
+#if __cplusplus <= 201402L
+throw (A)
+#endif
+{}
int main ()
{
// Test that we don't allow incomplete types in an exception-specification
// for a definition, or at a call site.
+// { dg-do compile { target c++14_down } }
// { dg-options "-fpermissive -w" }
struct A; // { dg-message "" }
} o;
struct Raiser {
- Raiser() throw( int ) {throw 1;};
+ Raiser()
+#if __cplusplus <= 201402L
+ throw( int ) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ {throw 1;};
} raiser;
};
};
// PR c++/24817
+// { dg-do compile { target c++14_down } }
struct exception {};
template <typename T> void foo() throw(exception); // { dg-message "declaration" }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-1 }
template <typename T> void foo(); // { dg-error "exception" }
struct bar
typedef int IntArray[10];
IntArray i;
-void test_array() throw (IntArray)
+void test_array()
+#if __cplusplus <= 201402L
+throw (IntArray) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
throw i;
}
{
typedef B<T> D;
typedef typename D::E E;
- void f() throw(E) { throw E(); }
+ void f()
+#if __cplusplus <= 201402L
+ throw(E) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ { throw E(); }
};
int main()
// PR 3719
// Test that an unexpected handler can rethrow to categorize.
-// { dg-do run }
+// { dg-do run { target c++14_down } }
#include <exception>
}
static void
-doit () throw (Two)
+doit () throw (Two) // { dg-warning "deprecated" "" { target { c++11 } } }
{
throw One ();
}
struct C
: public A { };
+#if __cplusplus > 201402L
+#define THROW_INT
+#else
+#define THROW_INT throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+
struct D
{
D& operator=(const D&) throw() { return *this; }
struct E
{
- E& operator=(const E&) throw(int) { return *this; }
+ E& operator=(const E&) THROW_INT { return *this; }
};
struct E1
{
- E1& operator=(const E1&) throw(int) { throw int(); return *this; }
+ E1& operator=(const E1&) THROW_INT { throw int(); return *this; }
};
struct F
{
- F() throw(int) { }
+ F() THROW_INT { }
};
struct G
{
- G() throw(int) { throw int(); }
+ G() THROW_INT { throw int(); }
};
struct H
{
- H& operator=(H&) throw(int) { return *this; }
+ H& operator=(H&) THROW_INT { return *this; }
};
struct H1
{
- H1& operator=(H1&) throw(int) { throw int(); return *this; }
+ H1& operator=(H1&) THROW_INT { throw int(); return *this; }
};
struct I
{
- I& operator=(I&) throw(int) { return *this; }
+ I& operator=(I&) THROW_INT { return *this; }
I& operator=(const I&) throw() { return *this; }
};
struct I1
{
- I1& operator=(I1&) throw(int) { throw int(); return *this; }
+ I1& operator=(I1&) THROW_INT { throw int(); return *this; }
I1& operator=(const I1&) throw() { return *this; }
};
A a;
};
+#if __cplusplus > 201402L
+#define THROW_INT
+#else
+#define THROW_INT throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+
struct C
: public A { };
struct E
{
- E() throw(int) { }
+ E() THROW_INT { }
};
struct E1
{
- E1() throw(int) { throw int(); }
+ E1() THROW_INT { throw int(); }
};
struct F
struct G
{
- G(const G&) throw(int) { throw int(); }
+ G(const G&) THROW_INT { throw int(); }
};
template<typename T>
struct C
: public A { };
+#if __cplusplus > 201402L
+#define THROW_INT
+#else
+#define THROW_INT throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+
struct D
{
D(const D&) throw() { }
struct E
{
- E(const E&) throw(int) { }
+ E(const E&) THROW_INT { }
};
struct E1
{
- E1(const E1&) throw(int) { throw int(); }
+ E1(const E1&) THROW_INT { throw int(); }
};
struct F
struct G
{
- G() throw(int) { throw int(); }
+ G() THROW_INT { throw int(); }
};
struct H
{
- H(H&) throw(int) { }
+ H(H&) THROW_INT { }
};
struct H1
{
- H1(H1&) throw(int) { throw int(); }
+ H1(H1&) THROW_INT { throw int(); }
};
struct I
{
- I(I&) throw(int) { }
+ I(I&) THROW_INT { }
I(const I&) throw() { }
};
struct I1
{
- I1(I1&) throw(int) { throw int(); }
+ I1(I1&) THROW_INT { throw int(); }
I1(const I1&) throw() { }
};
// { dg-do run }
#include <cassert>
-struct A { template <class T> A (T) throw (int); };
-struct B { B (B&) throw (); template <class T> B (T) throw (int); };
+struct A {
+ template <class T> A (T)
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
+};
+struct B {
+ B (B&) throw ();
+ template <class T> B (T)
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
+};
int main ()
{
struct S {
S (const S&) throw ();
- S (...) throw (int);
+ S (...)
+#if __cplusplus <= 201402L
+ throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
};
int main ()
struct S {
S (const S&) throw ();
- S (int) throw (int);
+ S (int)
+#if __cplusplus <= 201402L
+ throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
};
int main ()
struct S {
S (S&) throw ();
- S (const S&, int) throw (int);
+ S (const S&, int)
+#if __cplusplus <= 201402L
+ throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
};
int main ()
struct S {
S (const S&) throw ();
- S (S&&) throw (int);
+ S (S&&)
+#if __cplusplus <= 201402L
+ throw (int) // { dg-warning "deprecated" "" { target { ! c++1z } } }
+#endif
+ ;
};
int main ()
struct foo
{
- foo () throw (int)
+ foo ()
+#if __cplusplus <= 201402L
+ throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{ /* count (-) */
throw (1);
}
struct A
{
void* operator new(__SIZE_TYPE__) throw(X); // { dg-error "expected|type" }
-};
-
+}; // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-2 }
A* p = new A;
{
public:
void* operator new(std::size_t = 32) throw (std::bad_alloc); // { dg-error "first parameter" }
+ // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-2 }
void* operator new[](std::size_t = 32) throw (std::bad_alloc); // { dg-error "first parameter" }
+ // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
+ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-2 }
void* operator new(std::size_t = 32, const std::nothrow_t&) throw(); // { dg-error "first parameter" }
void* operator new[](std::size_t = 32, const std::nothrow_t&) throw(); // { dg-error "first parameter" }
};
{
class Test {
public:
- inline Test() throw( Exception );
- inline Test(int n ) throw( Exception );
+ inline Test()
+#if __cplusplus <= 201402L
+ throw( Exception ) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
+ inline Test(int n )
+#if __cplusplus <= 201402L
+ throw( Exception ) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
private:
int i;
};
// This line used to fail because Exception wasn't looked up in the
// right scope.
-ns::Test::Test() throw( Exception ) : i( 1 )
+ns::Test::Test()
+#if __cplusplus <= 201402L
+throw( Exception ) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+: i( 1 )
{
}
-ns::Test::Test( int n ) throw( Exception ) : i( n )
+ns::Test::Test( int n )
+#if __cplusplus <= 201402L
+throw( Exception ) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+: i( n )
{
}
};
struct infinint {
- void detruit() throw(Egeneric);
- template<class T> void infinint_from(T a) throw(Egeneric);
- infinint(long a = 0) throw(Egeneric) {
+ void detruit()
+#if __cplusplus <= 201402L
+ throw(Egeneric) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
+ template<class T> void infinint_from(T a)
+#if __cplusplus <= 201402L
+ throw(Egeneric) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
+ infinint(long a = 0)
+#if __cplusplus <= 201402L
+ throw(Egeneric) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ {
try {
infinint_from(a);
} catch(Egeneric& e) {
e.stack("infinint::infinint", "long");
}
}
- ~infinint() throw(Egeneric) {
+ ~infinint()
+#if __cplusplus <= 201402L
+ throw(Egeneric) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#else
+ noexcept(false)
+#endif
+ {
try {
detruit();
} catch(Egeneric& e) { }
// Test for proper error message formatting; the throw() should go inside
// the parens, as below.
-void (*g() throw())(); // { dg-message "g\\(\\) throw" "" }
+void (*g() throw())(); // { dg-message "g\\(\\) throw" "" { target { ! c++1z } } }
+ // { dg-message "g\\(\\) noexcept" "" { target c++1z } .-1 }
void (*g())(); // { dg-error "" "" }
class B {};
class C : public A, public B {};
class D : public C {};
-void f () throw (D)
+void f ()
+#if __cplusplus <= 201402L
+throw (D) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
}
// PR c++/23191
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
-// { dg-do compile }
+// { dg-do compile { target c++14_down } }
template<typename T> struct A
{
void foo() throw(typename T::X); // { dg-error "not a class" }
-};
+}; // { dg-warning "deprecated" "" { target c++11 } .-1 }
A<void> a; // { dg-message "required" }
// PR c++/37719.C
+// { dg-do compile { target c++14_down } }
template <typename T>
class foo {
void bar() throw(int); // { dg-message "throw \\(int\\)" }
-};
+}; // { dg-warning "deprecated" "" { target c++11 } .-1 }
template <>
void foo<int>::bar() throw(float) {} // { dg-error "throw \\(float\\)" }
+ // { dg-warning "deprecated" "" { target c++11 } .-1 }
typedef void (*new_handler)();
new_handler set_new_handler(new_handler) throw();
}
-void* operator new(std::size_t) throw (std::bad_alloc);
-void* operator new[](std::size_t) throw (std::bad_alloc);
+void* operator new(std::size_t)
+#if __cplusplus <= 201402L
+throw (std::bad_alloc) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+;
+void* operator new[](std::size_t)
+#if __cplusplus <= 201402L
+throw (std::bad_alloc) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+;
void operator delete(void*) throw();
void operator delete[](void*) throw();
void* operator new(std::size_t, const std::nothrow_t&) throw();
// { dg-do compile }
// { dg-options "-fgnu-tm" }
-void* operator new(__SIZE_TYPE__) throw (int);
+void* operator new(__SIZE_TYPE__)
+#if __cplusplus <= 201402L
+throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+;
void *point;
// { dg-do compile }
#include <string>
-void a() throw (int);
+void a()
+#if __cplusplus <= 201402L
+throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+;
void b(std::string const &);
void c(std::string *e)
struct Mutex
{
bool locked;
- ~Mutex () throw(int)
+ ~Mutex ()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
if (locked)
throw 0;
class free_list {
typedef __mutex __mutex_type;
__mutex_type& _M_get_mutex();
- void _M_get(size_t __sz) throw(bad_alloc);
+ void _M_get(size_t __sz)
+#if __cplusplus <= 201402L
+ throw(bad_alloc) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
};
-void free_list::_M_get(size_t __sz) throw(bad_alloc)
+void free_list::_M_get(size_t __sz)
+#if __cplusplus <= 201402L
+throw(bad_alloc) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
__mutex_type& __bfl_mutex = _M_get_mutex();
__bfl_mutex.unlock();
class UIException {
};
class PasswordDialog {
- void run() throw (UIException);
+ void run()
+#if __cplusplus <= 201402L
+ throw (UIException) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
};
class MessageBox {
public:
- MessageBox (std::string t) throw (UIException);
- virtual int run() throw (UIException) ;
+ MessageBox (std::string t)
+#if __cplusplus <= 201402L
+ throw (UIException) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
+ virtual int run()
+#if __cplusplus <= 201402L
+ throw (UIException) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
};
extern "C" {
struct __jmp_buf_tag {
typedef struct __jmp_buf_tag sigjmp_buf[1];
}
sigjmp_buf password_dialog_sig_jmp_buf;
-void PasswordDialog::run() throw (UIException)
+void PasswordDialog::run()
+#if __cplusplus <= 201402L
+throw (UIException) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
__sigsetjmp (password_dialog_sig_jmp_buf, 1);
MessageBox* errmsg = __null;
struct B {};
void
-foo (int size) throw (B,A)
+foo (int size)
+#if __cplusplus <= 201402L
+throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
char *p = (char*) __builtin_alloca (size + 1);
aligned i;
__attribute__ ((fastcall))
void
-foo (int j, int k, int m, int n, int o) throw (B,A)
+foo (int j, int k, int m, int n, int o)
+#if __cplusplus <= 201402L
+throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
aligned i;
struct B {};
void
-foo (void) throw (B,A)
+foo (void)
+#if __cplusplus <= 201402L
+throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
aligned i;
static void
inline __attribute__((always_inline))
-foo (void) throw (B,A)
+foo (void)
+#if __cplusplus <= 201402L
+throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
aligned i;
static void
inline __attribute__((always_inline))
-foo (int size) throw (B,A)
+foo (int size)
+#if __cplusplus <= 201402L
+throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
char *p = (char *) __builtin_alloca (size + 1);
aligned i;
__attribute__ ((thiscall))
void
-foo (int j, int k, int m, int n, int o) throw (B,A)
+foo (int j, int k, int m, int n, int o)
+#if __cplusplus <= 201402L
+throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
aligned i;
struct B {};
void
-foo (const char *fmt, ...) throw (B,A)
+foo (const char *fmt, ...)
+#if __cplusplus <= 201402L
+throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
va_list arg;
char *p;
struct B {};
void
-test (va_list arg) throw (B,A)
+test (va_list arg)
+#if __cplusplus <= 201402L
+throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
char *p;
aligned i;
} o;
struct Raiser {
- Raiser() throw( int ) {throw 1;};
+ Raiser()
+#if __cplusplus <= 201402L
+ throw( int ) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ {throw 1;};
} raiser;
};
};
struct E{};
-inline int bar() throw(E)
+inline int bar()
+#if __cplusplus <= 201402L
+throw(E) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
return 0;
}
return r;
}
-void fn_throw() throw(int)
+void fn_throw()
+#if __cplusplus <= 201402L
+throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
throw 1;
}
-void fn_rethrow() throw(int)
+void fn_rethrow()
+#if __cplusplus <= 201402L
+throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
try{fn_throw();}
catch(int a){
throw;}
}
-void fn_catchthrow() throw(int)
+void fn_catchthrow()
+#if __cplusplus <= 201402L
+throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
try{fn_throw();}
catch(int a){
struct X
{
- X (int) throw (int);
+ X (int)
+#if __cplusplus <= 201402L
+ throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
~X () throw ();
};
-X::X (int) throw (int)
+X::X (int)
+#if __cplusplus <= 201402L
+ throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{printf ("in ctor X %s\n", __PRETTY_FUNCTION__); bad = true;}
X::~X () throw ()
{printf ("in dtor X %s\n", __PRETTY_FUNCTION__); bad = true;}
struct X1 {};
struct Y : X
{
- Y() throw (int);
+ Y()
+#if __cplusplus <= 201402L
+ throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
~Y() throw ();
};
-Y::Y() throw (int)
+Y::Y()
+#if __cplusplus <= 201402L
+ throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
: X(thrower ()) // throws, so X::X is never called
{printf ("in ctor Y%s\n", __PRETTY_FUNCTION__); bad = true;}
Y::~Y() throw ()
-// { dg-do run }
+// { dg-do run { target c++14_down } }
// Testing exception specifications.
// Test 1: the original exception succeeds.
void my_unexp () { throw 42; }
void
-f () throw (char, int, std::bad_exception)
+f () throw (char, int, std::bad_exception) // { dg-warning "deprecated" "" { target c++11 } }
{
throw 'a';
}
-// { dg-do run }
+// { dg-do run { target c++14_down } }
// Testing exception specifications.
// Test 2: the second throw succeeds.
void my_unexp () { throw 42; }
void
-f () throw (int, std::bad_exception)
+f () throw (int, std::bad_exception) // { dg-warning "deprecated" "" { target c++11 } }
{
throw 'a';
}
-// { dg-do run }
+// { dg-do run { target c++14_down } }
// Testing exception specifications.
// Test 3: the bad_exception throw succeeds.
void my_unexp () { throw 42; }
void
-f () throw (std::bad_exception)
+f () throw (std::bad_exception) // { dg-warning "deprecated" "" { target c++11 } }
{
throw 'a';
}
-// { dg-do run }
+// { dg-do run { target c++14_down } }
// Testing exception specifications.
// Test 4: all throws fail, call terminate.
void my_unexp () { throw 42; }
void
-f () throw (short)
+f () throw (short) // { dg-warning "deprecated" "" { target c++11 } }
{
throw 'a';
}
-// { dg-do assemble }
+// { dg-do assemble { target c++14_down } }
+// { dg-additional-options "-Wno-deprecated" }
// Copyright (C) 1999 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 19 Jan 1999 <nathan@acm.org>
// { dg-do assemble }
-void athrow(const int & e) throw(int)
+void athrow(const int & e)
+#if __cplusplus <= 201402L
+throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
throw e;
}
#define ANY int // a class with a public constructor
-void athrow(const ANY & e) throw(ANY)
+void athrow(const ANY & e)
+#if __cplusplus <= 201402L
+throw(ANY) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
throw e; // { dg-bogus "" } discarding const
}
// { dg-do run }
template <class T>
-void f() throw (T)
+void f()
+#if __cplusplus <= 201402L
+throw (T) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
throw 7;
}
// Posted by Trevor Taylor <ttaylor@powerup.com.au>
template<class T> struct A {
- void X() throw(T);
+ void X()
+#if __cplusplus <= 201402L
+ throw(T) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
};
template<class T>
inline void A<T>::X()
-throw(T) { }
+#if __cplusplus <= 201402L
+throw(T) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+{ }
-// { dg-do assemble }
+// { dg-do assemble { target c++14_down } }
// { dg-options "-fexceptions" }
struct A {
- A() throw (int);
+ A() throw (int); // { dg-warning "deprecated" "" { target c++11 } }
};
struct A {
A() { }
- ~A() throw(int) {
+ ~A()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#else
+ noexcept(false)
+#endif
+ {
std::set_terminate (my_terminate);
throw 1; // This throws from EH dtor, should call my_terminate
}
// { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } }
+// { dg-require-effective-target c++14_down }
// { dg-options "-fexceptions" }
#include <exception>
throw 42;
}
-void foo() throw (int) { throw "Hi"; }
+void foo() throw (int) { throw "Hi"; } // { dg-warning "deprecated" "" { target c++11 } }
int main() {
std::set_unexpected (my_unexpected);
// { dg-do run { xfail sparc64-*-elf arm-*-pe } }
+// { dg-require-effective-target c++14_down }
#include <exception>
#include <stdlib.h>
// { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } }
+// { dg-require-effective-target c++14_down }
// { dg-options "-fexceptions" }
#include <exception>
throw 42;
}
-template <class T> void foo(T) throw (int) { throw "Hi"; }
+template <class T> void foo(T) throw (int) { throw "Hi"; } // { dg-warning "deprecated" "" { target c++11 } }
main() {
std::set_unexpected (my_unexpected);
// { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } }
+// { dg-require-effective-target c++14_down }
// { dg-options "-fexceptions" }
#include <exception>
throw 42;
}
-template <class T> void foo(T) throw (T) { throw "Hi"; }
+template <class T> void foo(T) throw (T) { throw "Hi"; } // { dg-warning "deprecated" "" { target c++11 } }
main() {
std::set_unexpected (my_unexpected);
}
void throw_an_unexpected_exception() throw() {
- throw 1;
+ throw 1; // { dg-warning "throw will always call terminate" "" { target c++1z } }
}
int main() {
class not_ok {
public:
- void f() throw(int) { }
+ void f()
+#if __cplusplus <= 201402L
+ throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ { }
};
bool b;
public:
foo();
- void x () throw(bar);
+ void x ()
+#if __cplusplus <= 201402L
+ throw(bar) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
+ ;
};
-void foo::x() throw(bar)
+void foo::x()
+#if __cplusplus <= 201402L
+throw(bar) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
if (!b) throw bar (static_cast<::N::X*>(this)); // { dg-error "lambda expressions|expected|invalid" } parse error
}
};
void foo::x() throw(bar) // { dg-error "" } parse error
-{
+{ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-1 }
}
void bar()
{
throw 1;
}
- void* operator new ( std::size_t n ) throw ( std::bad_alloc )
+ void* operator new ( std::size_t n )
+#if __cplusplus <= 201402L
+ throw ( std::bad_alloc ) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
new_flag = true;
return ::operator new( n );
-// { dg-do assemble }
+// { dg-do assemble { target c++14_down } }
// Bug: g++ forgets to instantiate A<int>
// Contributed by Jason Merrill <jason@cygnus.com>
template <class T> struct A { };
-void f () throw (A<int>);
+void f () throw (A<int>); // { dg-warning "deprecated" "" { target c++11 } }
// { dg-options "-O2 -W " }
#include "stdio.h"
-void writeNote() throw( int )
+void writeNote()
+#if __cplusplus <= 201402L
+throw( int ) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
+#endif
{
printf( "hello world\n" );
try { }
+2016-12-08 Jakub Jelinek <jakub@redhat.com>
+
+ * testsuite/util/testsuite_new_operators.h: Include testsuite_hooks.h.
+ (operator new): Use THROW macro.
+
2016-12-07 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_tree.h
#define _GLIBCXX_TESTSUITE_NEW_OPERATORS_H
#include <new>
+#include <testsuite_hooks.h>
namespace __gnu_test
{
{ get_new_limit() = l; }
}
-void* operator new(std::size_t size) throw(std::bad_alloc)
+void* operator new(std::size_t size) THROW(std::bad_alloc)
{
if (size > __gnu_test::get_new_limit())
throw std::bad_alloc();