Commit 1d09844a by Jakub Jelinek

P0003R5 - removal of dynamic exception specification from C++17

	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).

	* 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.

	* testsuite/util/testsuite_new_operators.h: Include testsuite_hooks.h.
	(operator new): Use THROW macro.

From-SVN: r243429
parent 23b88fda
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> 2016-12-07 Martin Jambor <mjambor@suse.cz>
PR c++/78589 PR c++/78589
......
...@@ -23786,7 +23786,7 @@ cp_parser_exception_specification_opt (cp_parser* parser) ...@@ -23786,7 +23786,7 @@ cp_parser_exception_specification_opt (cp_parser* parser)
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
/* Is it a noexcept-specification? */ /* Is it a noexcept-specification? */
type_id_list = cp_parser_noexcept_specification_opt(parser, true, NULL, type_id_list = cp_parser_noexcept_specification_opt (parser, true, NULL,
false); false);
if (type_id_list != NULL_TREE) if (type_id_list != NULL_TREE)
return type_id_list; return type_id_list;
...@@ -23795,12 +23795,7 @@ cp_parser_exception_specification_opt (cp_parser* parser) ...@@ -23795,12 +23795,7 @@ cp_parser_exception_specification_opt (cp_parser* parser)
if (!cp_parser_is_keyword (token, RID_THROW)) if (!cp_parser_is_keyword (token, RID_THROW))
return NULL_TREE; return NULL_TREE;
#if 0 location_t loc = token->location;
/* 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
/* Consume the `throw'. */ /* Consume the `throw'. */
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
...@@ -23821,7 +23816,23 @@ cp_parser_exception_specification_opt (cp_parser* parser) ...@@ -23821,7 +23816,23 @@ cp_parser_exception_specification_opt (cp_parser* parser)
type_id_list = cp_parser_type_id_list (parser); type_id_list = cp_parser_type_id_list (parser);
/* Restore the saved message. */ /* Restore the saved message. */
parser->type_definition_forbidden_message = 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 else
type_id_list = empty_except_spec; 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> 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> 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> 2016-12-07 Martin Sebor <msebor@redhat.com>
PR middle-end/77784 PR middle-end/77784
PR middle-end/78149 PR middle-end/78149
PR middle-end/78138 PR middle-end/78138
* c-c++-common/Wsizeof-pointer-memaccess2.c: Adjust expected diagnostic. * c-c++-common/Wsizeof-pointer-memaccess2.c: Adjust expected diagnostic.
* g++.dg/ext/builtin-object-size3.C (bar): Same. * g++.dg/ext/builtin-object-size3.C (bar): Same.
* g++.dg/ext/strncpy-chk1.C: Same. * g++.dg/ext/strncpy-chk1.C: Same.
...@@ -84,7 +185,7 @@ ...@@ -84,7 +185,7 @@
2016-12-07 Naveen H.S <Naveen.Hurugalawadi@cavium.com> 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-12-06 Tom de Vries <tom@codesourcery.com>
...@@ -873,23 +974,23 @@ ...@@ -873,23 +974,23 @@
2016-11-23 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com> 2016-11-23 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
* gcc.target/aarch64/ldp_stp_1.c : Add -mcpu=generic. * gcc.target/aarch64/ldp_stp_1.c: Add -mcpu=generic.
* gcc.target/aarch64/store-pair-1.c : Likewise. * gcc.target/aarch64/store-pair-1.c: Likewise.
2016-11-23 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com> 2016-11-23 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
* gcc.target/aarch64/fmaxmin.c : Add -fno-vect-cost-model. * gcc.target/aarch64/fmaxmin.c: Add -fno-vect-cost-model.
* gcc.target/aarch64/fmul_fcvt_2.c : Likewise. * gcc.target/aarch64/fmul_fcvt_2.c: Likewise.
* gcc.target/aarch64/vect-abs-compile.c : Likewise. * gcc.target/aarch64/vect-abs-compile.c: Likewise.
* gcc.target/aarch64/vect-clz.c : Likewise. * gcc.target/aarch64/vect-clz.c: Likewise.
* gcc.target/aarch64/vect-fcm-eq-d.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-ge-d.c: Likewise.
* gcc.target/aarch64/vect-fcm-gt-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-zero.c: Likewise.
* gcc.target/aarch64/vect-fmovd.c : Likewise. * gcc.target/aarch64/vect-fmovd.c: Likewise.
* gcc.target/aarch64/vect-fmovf-zero.c : Likewise. * gcc.target/aarch64/vect-fmovf-zero.c: Likewise.
* gcc.target/aarch64/vect-fmovf.c : Likewise. * gcc.target/aarch64/vect-fmovf.c: Likewise.
* gcc.target/aarch64/vect_ctz_1.c : Likewise. * gcc.target/aarch64/vect_ctz_1.c: Likewise.
2016-11-23 Peter Bergner <bergner@vnet.ibm.com> 2016-11-23 Peter Bergner <bergner@vnet.ibm.com>
...@@ -7061,7 +7162,7 @@ ...@@ -7061,7 +7162,7 @@
2016-07-28 Paul Thomas <pault@gcc.gnu.org> 2016-07-28 Paul Thomas <pault@gcc.gnu.org>
PR fortran/71883 PR fortran/71883
* gfortran.dg/pr71883.f90 : New test. * gfortran.dg/pr71883.f90: New test.
2016-07-28 Yuri Rumyantsev <ysrumyan@gmail.com> 2016-07-28 Yuri Rumyantsev <ysrumyan@gmail.com>
...@@ -14685,7 +14786,7 @@ ...@@ -14685,7 +14786,7 @@
2016-02-20 Paul Thomas <pault@gcc.gnu.org> 2016-02-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/69423 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> 2016-02-20 Dominique d'Humieres <dominiq@lps.ens.fr>
......
...@@ -5,6 +5,12 @@ struct Foo ...@@ -5,6 +5,12 @@ struct Foo
struct Bar struct Bar
{ {
~Bar () throw(int); ~Bar ()
#if __cplusplus < 201103L
throw(int)
#else
noexcept(false)
#endif
;
Foo f; Foo f;
}; };
...@@ -7,7 +7,12 @@ Foo::~Foo() ...@@ -7,7 +7,12 @@ Foo::~Foo()
was_f_in_Bar_destroyed=true; was_f_in_Bar_destroyed=true;
} }
Bar::~Bar() throw(int) Bar::~Bar()
#if __cplusplus < 201103L
throw(int)
#else
noexcept(false)
#endif
{ {
throw 1; throw 1;
} }
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
extern "C" void exit (int); extern "C" void exit (int);
extern "C" void abort (void); 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 (); extern void operator delete[] (void *p) throw ();
struct A struct A
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
extern int ret; extern int ret;
void *ptr; 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); ptr = operator new (s);
return ptr; return ptr;
......
#include "spec3.h" #include "spec3.h"
extern void func () throw (B,A); extern void func ()
#if __cplusplus < 201103L
throw (B,A)
#endif
;
void spec3_x (void) void spec3_x (void)
{ {
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
A::A() {} A::A() {}
void func() throw (B,A) void func()
#if __cplusplus < 201103L
throw (B,A)
#endif
{ {
throw A(); throw A();
} }
...@@ -11,5 +11,9 @@ struct C ...@@ -11,5 +11,9 @@ struct C
{ {
typedef B<T> D; typedef B<T> D;
typedef typename D::E E; typedef typename D::E E;
void f() throw(E); void f()
#if __cplusplus < 201103L
throw(E)
#endif
;
}; };
#include "template1.h" #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(); throw E();
} }
......
// { dg-options "-std=c++98" }
#include <exception> #include <exception>
struct One { }; struct One { };
......
// { dg-options "-std=c++98" }
struct One { }; struct One { };
struct Two { }; struct Two { };
......
...@@ -103,13 +103,13 @@ auto fnlate2 () -> auto *; // { dg-error "invalid use of|expected" "" { target ...@@ -103,13 +103,13 @@ auto fnlate2 () -> auto *; // { dg-error "invalid use of|expected" "" { target
void void
badthrow () throw (auto) // { dg-error "invalid use of" } 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 void
badthrow2 () throw (auto &) // { dg-error "invalid use of|expected" } 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 } } } template <auto V = 4> struct G {}; // { dg-error "auto" "" { target { ! c++1z } } }
......
...@@ -10,22 +10,22 @@ A a; ...@@ -10,22 +10,22 @@ A a;
struct B struct B
{ {
B() throw (int) = default; // { dg-message "exception-specification" } 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" } B b; // { dg-error "deleted" "" { target { ! c++1z } } }
struct C 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; C c;
struct D: 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; D d;
......
...@@ -39,7 +39,11 @@ namespace std ...@@ -39,7 +39,11 @@ namespace std
struct bad_alloc { }; 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 namespace std
{ {
......
// PR c++/47263 // PR c++/47263
// PR c++/49260 // PR c++/49260
// { dg-options "-fno-asynchronous-unwind-tables -fno-dwarf2-cfi-asm" } // { 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> #include <exception>
...@@ -10,7 +10,7 @@ int main( void ) ...@@ -10,7 +10,7 @@ int main( void )
std::set_unexpected( []{ throw 0; } ); std::set_unexpected( []{ throw 0; } );
try try
{ {
[]() throw( int ) { throw nullptr; }(); []() throw( int ) { throw nullptr; }(); // { dg-warning "deprecated" }
} }
catch( int ) catch( int )
{ } { }
......
...@@ -10,8 +10,10 @@ void f(); ...@@ -10,8 +10,10 @@ void f();
SA(!noexcept(f())); SA(!noexcept(f()));
void g() throw (int); // { dg-message "previous declaration" } void g() throw (int); // { dg-message "previous declaration" "" { target { ! c++1z } } }
void g() noexcept(false); // { dg-error "different exception" } // { 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 g();
void h() throw(); void h() throw();
......
// Test that checking of a nothrow specification uses the one on the // Test that checking of a nothrow specification uses the one on the
// definition. // definition. In C++17 throw() is equivalent to noexcept(true).
// { dg-do run { target c++11 } } // { dg-do run { target { c++11 && c++14_down } } }
#include <exception> #include <exception>
#include <cstdlib> #include <cstdlib>
......
...@@ -7,8 +7,8 @@ struct A ...@@ -7,8 +7,8 @@ struct A
virtual void g() throw(); virtual void g() throw();
virtual void h() noexcept; virtual void h() noexcept;
virtual void i() noexcept(false); 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 struct B: A
{ {
...@@ -34,16 +34,23 @@ struct D: A ...@@ -34,16 +34,23 @@ struct D: A
void g() noexcept(false); // { dg-error "looser" } void g() noexcept(false); // { dg-error "looser" }
void h() noexcept(false); // { dg-error "looser" } void h() noexcept(false); // { dg-error "looser" }
void i() noexcept(false); void i() noexcept(false);
void j() noexcept(false); // { dg-error "looser" } void j() noexcept(false); // { dg-error "looser" "" { target { ! c++1z } } }
}; };
struct E: A 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" } 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 h() throw(int); // { dg-error "looser" }
void i() throw(int); // { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
void j() throw(int); // { 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 struct F: A
...@@ -52,5 +59,5 @@ struct F: A ...@@ -52,5 +59,5 @@ struct F: A
void g(); // { dg-error "looser" } void g(); // { dg-error "looser" }
void h(); // { dg-error "looser" } void h(); // { dg-error "looser" }
void i(); void i();
void j(); // { dg-error "looser" } void j(); // { dg-error "looser" "" { target { ! c++1z } } }
}; };
...@@ -22,7 +22,11 @@ struct C ...@@ -22,7 +22,11 @@ struct C
struct D struct D
{ {
D () throw (int); D ()
#if __cplusplus <= 201402L
throw (int) // { dg-warning "deprecated" "" { target { ! c++1z } } }
#endif
;
}; };
C <D, B <D>> c; C <D, B <D>> c;
...@@ -9,9 +9,9 @@ template<int M, int N> struct pair ...@@ -9,9 +9,9 @@ template<int M, int N> struct pair
template<int... M> struct S template<int... M> struct S
{ {
template<int... N> static int foo() throw (pair <M, N>...) // { dg-error "mismatched" } 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; return 1; // { dg-warning "deprecated" "" { target { ! c++1z } } .-2 }
} }
}; };
...@@ -22,5 +22,5 @@ int bar () ...@@ -22,5 +22,5 @@ int bar ()
int wibble() 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 } } }
} }
...@@ -3,7 +3,11 @@ struct A {}; ...@@ -3,7 +3,11 @@ struct A {};
struct B {}; struct B {};
struct C {}; 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(); if (idx == 0) throw A();
else if (idx == 1) throw B(); else if (idx == 1) throw B();
else if (idx == 2) throw C(); else if (idx == 2) throw C();
......
// Testcase from P0012r1 // Testcase from P0012r1
// { dg-options -std=c++1z } // { 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 void (**pp)() noexcept = &p; // { dg-error "" } cannot convert to pointer to noexcept function
struct S { typedef void (*p)(); operator p(); }; struct S { typedef void (*p)(); operator p(); };
......
...@@ -87,8 +87,16 @@ struct Y ...@@ -87,8 +87,16 @@ struct Y
struct Z; struct Z;
X <V> baz1 (const S &) throw (E); X <V> baz1 (const S &)
X <Z> baz2 (const X <Z> &) throw (E); #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 () template <typename T> X<T>::X ()
{ {
...@@ -112,7 +120,10 @@ template <typename T> T *X<T>::operator -> () const ...@@ -112,7 +120,10 @@ template <typename T> T *X<T>::operator -> () const
return &y; 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> (); return X<V> ();
} }
...@@ -125,7 +136,10 @@ E::~E () ...@@ -125,7 +136,10 @@ E::~E ()
{ {
} }
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 (); throw E ();
} }
......
...@@ -12,7 +12,13 @@ void my_terminate () ...@@ -12,7 +12,13 @@ void my_terminate ()
struct A { struct A {
A(int) { } 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 { struct B {
B(A) { } B(A) { }
......
...@@ -12,7 +12,13 @@ void operator delete (void *) throw () ...@@ -12,7 +12,13 @@ void operator delete (void *) throw ()
} }
struct Foo { 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 { struct Baz {
...@@ -20,7 +26,13 @@ struct Baz { ...@@ -20,7 +26,13 @@ struct Baz {
{ {
deleted = 2; 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 () int non_virt ()
......
...@@ -15,7 +15,13 @@ class A<int, int> ...@@ -15,7 +15,13 @@ class A<int, int>
public: public:
A(int) { ++count; if (b) throw 1; } A(int) { ++count; if (b) throw 1; }
A(const A&) { ++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; typedef A<int, int> B;
...@@ -26,7 +32,13 @@ class A<void *, void *> ...@@ -26,7 +32,13 @@ class A<void *, void *>
public: public:
A() { if (b) throw 1; } A() { if (b) throw 1; }
A(const B&) { 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; typedef A<void *, void *> C;
......
// HP-UX libunwind.so doesn't provide _UA_END_OF_STACK. // HP-UX libunwind.so doesn't provide _UA_END_OF_STACK.
// { dg-do run { xfail "ia64-hp-hpux11.*" } } // { dg-do run { xfail "ia64-hp-hpux11.*" } }
// { dg-require-effective-target c++14_down }
// Test that forced unwinding calls std::unexpected going // Test that forced unwinding calls std::unexpected going
// through a nothrow function. // through a nothrow function.
......
...@@ -38,7 +38,10 @@ force_unwind () ...@@ -38,7 +38,10 @@ force_unwind ()
} }
static void static void
doit () throw(int) doit ()
#if __cplusplus <= 201402L
throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
#endif
{ {
force_unwind (); force_unwind ();
} }
......
...@@ -8,18 +8,36 @@ template <class _Tp> class AutoPtr ...@@ -8,18 +8,36 @@ template <class _Tp> class AutoPtr
public: public:
explicit AutoPtr(_Tp* __p = 0) : _M_ptr(__p) {} 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 struct A
{ {
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 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; } B* f (const A &s) { throw 1; }
......
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
class E { }; class E { };
class T { 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))); int bar(bool b) __attribute__((regparm(1)));
}; };
......
...@@ -15,7 +15,10 @@ void f1() ...@@ -15,7 +15,10 @@ void f1()
try {} catch (...) {} // { dg-error "" } 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(); bar();
} }
...@@ -13,14 +13,14 @@ struct D : private B ...@@ -13,14 +13,14 @@ struct D : private B
friend class E; friend class E;
static B *baz (D *); 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 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* foo (D *);
B *D::baz (D *p) B *D::baz (D *p)
......
...@@ -3,8 +3,15 @@ ...@@ -3,8 +3,15 @@
struct S { void f (void); }; struct S { void f (void); };
typedef void f1 (void) throw (int); // { dg-error "exception" "" { target c++14_down } } 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 } } 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 } } typedef void (S::*f3) (void) throw (int); // { dg-error "exception" "" { target c++14_down } }
// { dg-error "dynamic exception specification" "" { target c++1z } .-1 }
void (*f4) (void) throw (int); // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-2 }
void (S::*f5) (void) throw (int); 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 }
...@@ -12,7 +12,10 @@ struct A : virtual public Base ...@@ -12,7 +12,10 @@ struct A : virtual public Base
struct B {}; 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(); throw A();
} }
......
...@@ -8,12 +8,20 @@ struct A; ...@@ -8,12 +8,20 @@ struct A;
struct B struct B
{ {
void f () throw (A); void f ()
#if __cplusplus <= 201402L
throw (A)
#endif
;
}; };
struct A {}; struct A {};
void B::f () throw (A) {} void B::f ()
#if __cplusplus <= 201402L
throw (A)
#endif
{}
int main () int main ()
{ {
......
// Test that we don't allow incomplete types in an exception-specification // Test that we don't allow incomplete types in an exception-specification
// for a definition, or at a call site. // for a definition, or at a call site.
// { dg-do compile { target c++14_down } }
// { dg-options "-fpermissive -w" } // { dg-options "-fpermissive -w" }
struct A; // { dg-message "" } struct A; // { dg-message "" }
......
...@@ -19,7 +19,11 @@ struct D : public B { ...@@ -19,7 +19,11 @@ struct D : public B {
} o; } o;
struct Raiser { 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; } raiser;
}; };
}; };
......
// PR c++/24817 // PR c++/24817
// { dg-do compile { target c++14_down } }
struct exception {}; struct exception {};
template <typename T> void foo() throw(exception); // { dg-message "declaration" } 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" } template <typename T> void foo(); // { dg-error "exception" }
struct bar struct bar
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
typedef int IntArray[10]; typedef int IntArray[10];
IntArray i; 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; throw i;
} }
......
...@@ -17,7 +17,11 @@ struct C ...@@ -17,7 +17,11 @@ struct C
{ {
typedef B<T> D; typedef B<T> D;
typedef typename D::E E; 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() int main()
......
// PR 3719 // PR 3719
// Test that an unexpected handler can rethrow to categorize. // Test that an unexpected handler can rethrow to categorize.
// { dg-do run } // { dg-do run { target c++14_down } }
#include <exception> #include <exception>
...@@ -23,7 +23,7 @@ handle_unexpected () ...@@ -23,7 +23,7 @@ handle_unexpected ()
} }
static void static void
doit () throw (Two) doit () throw (Two) // { dg-warning "deprecated" "" { target { c++11 } } }
{ {
throw One (); throw One ();
} }
......
...@@ -15,6 +15,12 @@ struct B ...@@ -15,6 +15,12 @@ struct B
struct C struct C
: public A { }; : 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 struct D
{ {
D& operator=(const D&) throw() { return *this; } D& operator=(const D&) throw() { return *this; }
...@@ -22,43 +28,43 @@ struct D ...@@ -22,43 +28,43 @@ struct D
struct E struct E
{ {
E& operator=(const E&) throw(int) { return *this; } E& operator=(const E&) THROW_INT { return *this; }
}; };
struct E1 struct E1
{ {
E1& operator=(const E1&) throw(int) { throw int(); return *this; } E1& operator=(const E1&) THROW_INT { throw int(); return *this; }
}; };
struct F struct F
{ {
F() throw(int) { } F() THROW_INT { }
}; };
struct G struct G
{ {
G() throw(int) { throw int(); } G() THROW_INT { throw int(); }
}; };
struct H struct H
{ {
H& operator=(H&) throw(int) { return *this; } H& operator=(H&) THROW_INT { return *this; }
}; };
struct H1 struct H1
{ {
H1& operator=(H1&) throw(int) { throw int(); return *this; } H1& operator=(H1&) THROW_INT { throw int(); return *this; }
}; };
struct I struct I
{ {
I& operator=(I&) throw(int) { return *this; } I& operator=(I&) THROW_INT { return *this; }
I& operator=(const I&) throw() { return *this; } I& operator=(const I&) throw() { return *this; }
}; };
struct I1 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; } I1& operator=(const I1&) throw() { return *this; }
}; };
......
...@@ -12,6 +12,12 @@ struct B ...@@ -12,6 +12,12 @@ struct B
A a; 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 struct C
: public A { }; : public A { };
...@@ -22,12 +28,12 @@ struct D ...@@ -22,12 +28,12 @@ struct D
struct E struct E
{ {
E() throw(int) { } E() THROW_INT { }
}; };
struct E1 struct E1
{ {
E1() throw(int) { throw int(); } E1() THROW_INT { throw int(); }
}; };
struct F struct F
...@@ -37,7 +43,7 @@ struct F ...@@ -37,7 +43,7 @@ struct F
struct G struct G
{ {
G(const G&) throw(int) { throw int(); } G(const G&) THROW_INT { throw int(); }
}; };
template<typename T> template<typename T>
......
...@@ -15,6 +15,12 @@ struct B ...@@ -15,6 +15,12 @@ struct B
struct C struct C
: public A { }; : 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 struct D
{ {
D(const D&) throw() { } D(const D&) throw() { }
...@@ -22,12 +28,12 @@ struct D ...@@ -22,12 +28,12 @@ struct D
struct E struct E
{ {
E(const E&) throw(int) { } E(const E&) THROW_INT { }
}; };
struct E1 struct E1
{ {
E1(const E1&) throw(int) { throw int(); } E1(const E1&) THROW_INT { throw int(); }
}; };
struct F struct F
...@@ -37,28 +43,28 @@ struct F ...@@ -37,28 +43,28 @@ struct F
struct G struct G
{ {
G() throw(int) { throw int(); } G() THROW_INT { throw int(); }
}; };
struct H struct H
{ {
H(H&) throw(int) { } H(H&) THROW_INT { }
}; };
struct H1 struct H1
{ {
H1(H1&) throw(int) { throw int(); } H1(H1&) THROW_INT { throw int(); }
}; };
struct I struct I
{ {
I(I&) throw(int) { } I(I&) THROW_INT { }
I(const I&) throw() { } I(const I&) throw() { }
}; };
struct I1 struct I1
{ {
I1(I1&) throw(int) { throw int(); } I1(I1&) THROW_INT { throw int(); }
I1(const I1&) throw() { } I1(const I1&) throw() { }
}; };
......
...@@ -2,8 +2,21 @@ ...@@ -2,8 +2,21 @@
// { dg-do run } // { dg-do run }
#include <cassert> #include <cassert>
struct A { template <class T> A (T) throw (int); }; struct A {
struct B { B (B&) throw (); template <class T> B (T) throw (int); }; 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 () int main ()
{ {
......
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
struct S { struct S {
S (const S&) throw (); S (const S&) throw ();
S (...) throw (int); S (...)
#if __cplusplus <= 201402L
throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
#endif
;
}; };
int main () int main ()
......
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
struct S { struct S {
S (const S&) throw (); 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 () int main ()
......
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
struct S { struct S {
S (S&) throw (); 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 () int main ()
......
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
struct S { struct S {
S (const S&) throw (); S (const S&) throw ();
S (S&&) throw (int); S (S&&)
#if __cplusplus <= 201402L
throw (int) // { dg-warning "deprecated" "" { target { ! c++1z } } }
#endif
;
}; };
int main () int main ()
......
...@@ -7,7 +7,10 @@ ...@@ -7,7 +7,10 @@
struct foo struct foo
{ {
foo () throw (int) foo ()
#if __cplusplus <= 201402L
throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
#endif
{ /* count (-) */ { /* count (-) */
throw (1); throw (1);
} }
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
struct A struct A
{ {
void* operator new(__SIZE_TYPE__) throw(X); // { dg-error "expected|type" } 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; A* p = new A;
...@@ -5,7 +5,11 @@ class C ...@@ -5,7 +5,11 @@ class C
{ {
public: public:
void* operator new(std::size_t = 32) throw (std::bad_alloc); // { dg-error "first parameter" } 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" } 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" }
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" }
}; };
......
...@@ -11,8 +11,16 @@ namespace ns ...@@ -11,8 +11,16 @@ namespace ns
{ {
class Test { class Test {
public: public:
inline Test() throw( Exception ); inline Test()
inline Test(int n ) throw( Exception ); #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: private:
int i; int i;
}; };
...@@ -20,11 +28,19 @@ namespace ns ...@@ -20,11 +28,19 @@ namespace ns
// This line used to fail because Exception wasn't looked up in the // This line used to fail because Exception wasn't looked up in the
// right scope. // 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 )
{ {
} }
......
...@@ -58,16 +58,34 @@ struct Egeneric { ...@@ -58,16 +58,34 @@ struct Egeneric {
}; };
struct infinint { struct infinint {
void detruit() throw(Egeneric); void detruit()
template<class T> void infinint_from(T a) throw(Egeneric); #if __cplusplus <= 201402L
infinint(long a = 0) throw(Egeneric) { 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 { try {
infinint_from(a); infinint_from(a);
} catch(Egeneric& e) { } catch(Egeneric& e) {
e.stack("infinint::infinint", "long"); 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 { try {
detruit(); detruit();
} catch(Egeneric& e) { } } catch(Egeneric& e) { }
......
// Test for proper error message formatting; the throw() should go inside // Test for proper error message formatting; the throw() should go inside
// the parens, as below. // 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 "" "" } void (*g())(); // { dg-error "" "" }
...@@ -5,6 +5,9 @@ class A {}; ...@@ -5,6 +5,9 @@ class A {};
class B {}; class B {};
class C : public A, public B {}; class C : public A, public B {};
class D : public C {}; 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 // PR c++/23191
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de> // Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
// { dg-do compile } // { dg-do compile { target c++14_down } }
template<typename T> struct A template<typename T> struct A
{ {
void foo() throw(typename T::X); // { dg-error "not a class" } void foo() throw(typename T::X); // { dg-error "not a class" }
}; }; // { dg-warning "deprecated" "" { target c++11 } .-1 }
A<void> a; // { dg-message "required" } A<void> a; // { dg-message "required" }
// PR c++/37719.C // PR c++/37719.C
// { dg-do compile { target c++14_down } }
template <typename T> template <typename T>
class foo { class foo {
void bar() throw(int); // { dg-message "throw \\(int\\)" } void bar() throw(int); // { dg-message "throw \\(int\\)" }
}; }; // { dg-warning "deprecated" "" { target c++11 } .-1 }
template <> template <>
void foo<int>::bar() throw(float) {} // { dg-error "throw \\(float\\)" } void foo<int>::bar() throw(float) {} // { dg-error "throw \\(float\\)" }
// { dg-warning "deprecated" "" { target c++11 } .-1 }
...@@ -1667,8 +1667,16 @@ namespace std ...@@ -1667,8 +1667,16 @@ namespace std
typedef void (*new_handler)(); typedef void (*new_handler)();
new_handler set_new_handler(new_handler) throw(); new_handler set_new_handler(new_handler) throw();
} }
void* operator new(std::size_t) throw (std::bad_alloc); void* operator new(std::size_t)
void* operator new[](std::size_t) throw (std::bad_alloc); #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 delete[](void*) throw(); void operator delete[](void*) throw();
void* operator new(std::size_t, const std::nothrow_t&) throw(); void* operator new(std::size_t, const std::nothrow_t&) throw();
......
// { dg-do compile } // { dg-do compile }
// { dg-options "-fgnu-tm" } // { 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; void *point;
......
// { dg-do compile } // { dg-do compile }
#include <string> #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 b(std::string const &);
void c(std::string *e) void c(std::string *e)
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
struct Mutex struct Mutex
{ {
bool locked; bool locked;
~Mutex () throw(int) ~Mutex ()
#if __cplusplus <= 201402L
throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
#endif
{ {
if (locked) if (locked)
throw 0; throw 0;
......
...@@ -21,9 +21,16 @@ public: ...@@ -21,9 +21,16 @@ public:
class free_list { class free_list {
typedef __mutex __mutex_type; typedef __mutex __mutex_type;
__mutex_type& _M_get_mutex(); __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(); __mutex_type& __bfl_mutex = _M_get_mutex();
__bfl_mutex.unlock(); __bfl_mutex.unlock();
......
...@@ -19,12 +19,24 @@ namespace std { ...@@ -19,12 +19,24 @@ namespace std {
class UIException { class UIException {
}; };
class PasswordDialog { class PasswordDialog {
void run() throw (UIException); void run()
#if __cplusplus <= 201402L
throw (UIException) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
#endif
;
}; };
class MessageBox { class MessageBox {
public: public:
MessageBox (std::string t) throw (UIException); MessageBox (std::string t)
virtual int run() throw (UIException) ; #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" { extern "C" {
struct __jmp_buf_tag { struct __jmp_buf_tag {
...@@ -33,7 +45,10 @@ extern "C" { ...@@ -33,7 +45,10 @@ extern "C" {
typedef struct __jmp_buf_tag sigjmp_buf[1]; typedef struct __jmp_buf_tag sigjmp_buf[1];
} }
sigjmp_buf password_dialog_sig_jmp_buf; 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); __sigsetjmp (password_dialog_sig_jmp_buf, 1);
MessageBox* errmsg = __null; MessageBox* errmsg = __null;
......
...@@ -27,7 +27,10 @@ struct A : virtual public Base ...@@ -27,7 +27,10 @@ struct A : virtual public Base
struct B {}; struct B {};
void 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); char *p = (char*) __builtin_alloca (size + 1);
aligned i; aligned i;
......
...@@ -21,7 +21,10 @@ struct B {}; ...@@ -21,7 +21,10 @@ struct B {};
__attribute__ ((fastcall)) __attribute__ ((fastcall))
void 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; aligned i;
......
...@@ -21,7 +21,10 @@ struct A : virtual public Base ...@@ -21,7 +21,10 @@ struct A : virtual public Base
struct B {}; struct B {};
void 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; aligned i;
......
...@@ -22,7 +22,10 @@ struct B {}; ...@@ -22,7 +22,10 @@ struct B {};
static void static void
inline __attribute__((always_inline)) 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; aligned i;
......
...@@ -28,7 +28,10 @@ struct B {}; ...@@ -28,7 +28,10 @@ struct B {};
static void static void
inline __attribute__((always_inline)) 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); char *p = (char *) __builtin_alloca (size + 1);
aligned i; aligned i;
......
...@@ -21,7 +21,10 @@ struct B {}; ...@@ -21,7 +21,10 @@ struct B {};
__attribute__ ((thiscall)) __attribute__ ((thiscall))
void 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; aligned i;
......
...@@ -28,7 +28,10 @@ struct A : virtual public Base ...@@ -28,7 +28,10 @@ struct A : virtual public Base
struct B {}; struct B {};
void 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; va_list arg;
char *p; char *p;
......
...@@ -29,7 +29,10 @@ struct A : virtual public Base ...@@ -29,7 +29,10 @@ struct A : virtual public Base
struct B {}; struct B {};
void 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; char *p;
aligned i; aligned i;
......
...@@ -15,7 +15,11 @@ struct D : public B { ...@@ -15,7 +15,11 @@ struct D : public B {
} o; } o;
struct Raiser { 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; } raiser;
}; };
}; };
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
struct E{}; 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 0;
} }
......
...@@ -93,19 +93,28 @@ extern "C" void *realloc (void *p, size_t size) ...@@ -93,19 +93,28 @@ extern "C" void *realloc (void *p, size_t size)
return r; 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; 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();} try{fn_throw();}
catch(int a){ catch(int a){
throw;} 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();} try{fn_throw();}
catch(int a){ catch(int a){
......
...@@ -18,11 +18,18 @@ static int thrower () ...@@ -18,11 +18,18 @@ static int thrower ()
struct X 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 () 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;} {printf ("in ctor X %s\n", __PRETTY_FUNCTION__); bad = true;}
X::~X () throw () X::~X () throw ()
{printf ("in dtor X %s\n", __PRETTY_FUNCTION__); bad = true;} {printf ("in dtor X %s\n", __PRETTY_FUNCTION__); bad = true;}
...@@ -30,10 +37,17 @@ X::~X () throw () ...@@ -30,10 +37,17 @@ X::~X () throw ()
struct X1 {}; struct X1 {};
struct Y : X struct Y : X
{ {
Y() throw (int); Y()
#if __cplusplus <= 201402L
throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
#endif
;
~Y() throw (); ~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 : X(thrower ()) // throws, so X::X is never called
{printf ("in ctor Y%s\n", __PRETTY_FUNCTION__); bad = true;} {printf ("in ctor Y%s\n", __PRETTY_FUNCTION__); bad = true;}
Y::~Y() throw () Y::~Y() throw ()
......
// { dg-do run } // { dg-do run { target c++14_down } }
// Testing exception specifications. // Testing exception specifications.
// Test 1: the original exception succeeds. // Test 1: the original exception succeeds.
...@@ -9,7 +9,7 @@ void my_term () { exit (1); } ...@@ -9,7 +9,7 @@ void my_term () { exit (1); }
void my_unexp () { throw 42; } void my_unexp () { throw 42; }
void void
f () throw (char, int, std::bad_exception) f () throw (char, int, std::bad_exception) // { dg-warning "deprecated" "" { target c++11 } }
{ {
throw 'a'; throw 'a';
} }
......
// { dg-do run } // { dg-do run { target c++14_down } }
// Testing exception specifications. // Testing exception specifications.
// Test 2: the second throw succeeds. // Test 2: the second throw succeeds.
...@@ -9,7 +9,7 @@ void my_term () { exit (1); } ...@@ -9,7 +9,7 @@ void my_term () { exit (1); }
void my_unexp () { throw 42; } void my_unexp () { throw 42; }
void void
f () throw (int, std::bad_exception) f () throw (int, std::bad_exception) // { dg-warning "deprecated" "" { target c++11 } }
{ {
throw 'a'; throw 'a';
} }
......
// { dg-do run } // { dg-do run { target c++14_down } }
// Testing exception specifications. // Testing exception specifications.
// Test 3: the bad_exception throw succeeds. // Test 3: the bad_exception throw succeeds.
...@@ -9,7 +9,7 @@ void my_term () { exit (1); } ...@@ -9,7 +9,7 @@ void my_term () { exit (1); }
void my_unexp () { throw 42; } void my_unexp () { throw 42; }
void void
f () throw (std::bad_exception) f () throw (std::bad_exception) // { dg-warning "deprecated" "" { target c++11 } }
{ {
throw 'a'; throw 'a';
} }
......
// { dg-do run } // { dg-do run { target c++14_down } }
// Testing exception specifications. // Testing exception specifications.
// Test 4: all throws fail, call terminate. // Test 4: all throws fail, call terminate.
...@@ -9,7 +9,7 @@ void my_term () { exit (0); } ...@@ -9,7 +9,7 @@ void my_term () { exit (0); }
void my_unexp () { throw 42; } void my_unexp () { throw 42; }
void void
f () throw (short) f () throw (short) // { dg-warning "deprecated" "" { target c++11 } }
{ {
throw 'a'; throw 'a';
} }
......
// { dg-do assemble } // { dg-do assemble { target c++14_down } }
// { dg-additional-options "-Wno-deprecated" }
// Copyright (C) 1999 Free Software Foundation, Inc. // Copyright (C) 1999 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 19 Jan 1999 <nathan@acm.org> // Contributed by Nathan Sidwell 19 Jan 1999 <nathan@acm.org>
......
// { dg-do assemble } // { 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; throw e;
} }
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
#define ANY int // a class with a public constructor #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 throw e; // { dg-bogus "" } discarding const
} }
......
// { dg-do run } // { dg-do run }
template <class T> 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; throw 7;
} }
......
...@@ -3,9 +3,16 @@ ...@@ -3,9 +3,16 @@
// Posted by Trevor Taylor <ttaylor@powerup.com.au> // Posted by Trevor Taylor <ttaylor@powerup.com.au>
template<class T> struct A { 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> template<class T>
inline void A<T>::X() 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" } // { dg-options "-fexceptions" }
struct A { struct A {
A() throw (int); A() throw (int); // { dg-warning "deprecated" "" { target c++11 } }
}; };
...@@ -10,7 +10,13 @@ void my_terminate() { ...@@ -10,7 +10,13 @@ void my_terminate() {
struct A { struct A {
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); std::set_terminate (my_terminate);
throw 1; // This throws from EH dtor, should call my_terminate throw 1; // This throws from EH dtor, should call my_terminate
} }
......
// { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } } // { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } }
// { dg-require-effective-target c++14_down }
// { dg-options "-fexceptions" } // { dg-options "-fexceptions" }
#include <exception> #include <exception>
...@@ -7,7 +8,7 @@ void my_unexpected() { ...@@ -7,7 +8,7 @@ void my_unexpected() {
throw 42; throw 42;
} }
void foo() throw (int) { throw "Hi"; } void foo() throw (int) { throw "Hi"; } // { dg-warning "deprecated" "" { target c++11 } }
int main() { int main() {
std::set_unexpected (my_unexpected); std::set_unexpected (my_unexpected);
......
// { dg-do run { xfail sparc64-*-elf arm-*-pe } } // { dg-do run { xfail sparc64-*-elf arm-*-pe } }
// { dg-require-effective-target c++14_down }
#include <exception> #include <exception>
#include <stdlib.h> #include <stdlib.h>
......
// { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } } // { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } }
// { dg-require-effective-target c++14_down }
// { dg-options "-fexceptions" } // { dg-options "-fexceptions" }
#include <exception> #include <exception>
...@@ -7,7 +8,7 @@ void my_unexpected() { ...@@ -7,7 +8,7 @@ void my_unexpected() {
throw 42; 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() { main() {
std::set_unexpected (my_unexpected); std::set_unexpected (my_unexpected);
......
// { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } } // { dg-do run { xfail sparc64-*-elf z8k-*-* arm-*-pe } }
// { dg-require-effective-target c++14_down }
// { dg-options "-fexceptions" } // { dg-options "-fexceptions" }
#include <exception> #include <exception>
...@@ -7,7 +8,7 @@ void my_unexpected() { ...@@ -7,7 +8,7 @@ void my_unexpected() {
throw 42; 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() { main() {
std::set_unexpected (my_unexpected); std::set_unexpected (my_unexpected);
......
...@@ -9,7 +9,7 @@ void my_terminate_handler() { ...@@ -9,7 +9,7 @@ void my_terminate_handler() {
} }
void throw_an_unexpected_exception() throw() { void throw_an_unexpected_exception() throw() {
throw 1; throw 1; // { dg-warning "throw will always call terminate" "" { target c++1z } }
} }
int main() { int main() {
......
...@@ -5,5 +5,9 @@ ...@@ -5,5 +5,9 @@
class not_ok { class not_ok {
public: public:
void f() throw(int) { } void f()
#if __cplusplus <= 201402L
throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
#endif
{ }
}; };
...@@ -27,9 +27,16 @@ class foo ...@@ -27,9 +27,16 @@ class foo
bool b; bool b;
public: public:
foo(); 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 if (!b) throw bar (static_cast<::N::X*>(this)); // { dg-error "lambda expressions|expected|invalid" } parse error
} }
...@@ -8,7 +8,7 @@ struct foo ...@@ -8,7 +8,7 @@ struct foo
}; };
void foo::x() throw(bar) // { dg-error "" } parse error void foo::x() throw(bar) // { dg-error "" } parse error
{ { // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-1 }
} }
void bar() void bar()
......
...@@ -13,7 +13,10 @@ struct X { ...@@ -13,7 +13,10 @@ struct X {
{ {
throw 1; 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; new_flag = true;
return ::operator new( n ); return ::operator new( n );
......
// { dg-do assemble } // { dg-do assemble { target c++14_down } }
// Bug: g++ forgets to instantiate A<int> // Bug: g++ forgets to instantiate A<int>
// Contributed by Jason Merrill <jason@cygnus.com> // Contributed by Jason Merrill <jason@cygnus.com>
template <class T> struct A { }; template <class T> struct A { };
void f () throw (A<int>); void f () throw (A<int>); // { dg-warning "deprecated" "" { target c++11 } }
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
// { dg-options "-O2 -W " } // { dg-options "-O2 -W " }
#include "stdio.h" #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" ); printf( "hello world\n" );
try { } 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> 2016-12-07 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_tree.h * include/bits/stl_tree.h
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define _GLIBCXX_TESTSUITE_NEW_OPERATORS_H #define _GLIBCXX_TESTSUITE_NEW_OPERATORS_H
#include <new> #include <new>
#include <testsuite_hooks.h>
namespace __gnu_test namespace __gnu_test
{ {
...@@ -38,7 +39,7 @@ namespace __gnu_test ...@@ -38,7 +39,7 @@ namespace __gnu_test
{ get_new_limit() = l; } { 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()) if (size > __gnu_test::get_new_limit())
throw std::bad_alloc(); throw std::bad_alloc();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment