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>
PR c++/78589
......
......@@ -23786,8 +23786,8 @@ cp_parser_exception_specification_opt (cp_parser* parser)
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;
......@@ -23795,12 +23795,7 @@ cp_parser_exception_specification_opt (cp_parser* parser)
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);
......@@ -23821,7 +23816,23 @@ cp_parser_exception_specification_opt (cp_parser* parser)
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.
......@@ -84,7 +185,7 @@
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>
......@@ -873,23 +974,23 @@
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>
......@@ -7061,7 +7162,7 @@
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>
......@@ -14685,7 +14786,7 @@
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>
......
......@@ -5,6 +5,12 @@ struct Foo
struct Bar
{
~Bar () throw(int);
~Bar ()
#if __cplusplus < 201103L
throw(int)
#else
noexcept(false)
#endif
;
Foo f;
};
......@@ -7,7 +7,12 @@ Foo::~Foo()
was_f_in_Bar_destroyed=true;
}
Bar::~Bar() throw(int)
Bar::~Bar()
#if __cplusplus < 201103L
throw(int)
#else
noexcept(false)
#endif
{
throw 1;
}
......@@ -4,7 +4,11 @@
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
......
......@@ -4,7 +4,10 @@
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)
{
......
......@@ -2,7 +2,10 @@
A::A() {}
void func() throw (B,A)
void func()
#if __cplusplus < 201103L
throw (B,A)
#endif
{
throw A();
}
......@@ -11,5 +11,9 @@ struct C
{
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 { };
......
......@@ -103,13 +103,13 @@ auto fnlate2 () -> auto *; // { dg-error "invalid use of|expected" "" { target
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 } } }
......
......@@ -10,22 +10,22 @@ A a;
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;
......
......@@ -39,7 +39,11 @@ namespace std
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>
......@@ -10,7 +10,7 @@ int main( void )
std::set_unexpected( []{ throw 0; } );
try
{
[]() throw( int ) { throw nullptr; }();
[]() throw( int ) { throw nullptr; }(); // { dg-warning "deprecated" }
}
catch( int )
{ }
......
......@@ -10,8 +10,10 @@ void f();
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>
......
......@@ -7,8 +7,8 @@ struct A
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
{
......@@ -34,16 +34,23 @@ struct D: 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
......@@ -52,5 +59,5 @@ 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 } } }
};
......@@ -22,7 +22,11 @@ struct C
struct D
{
D () throw (int);
D ()
#if __cplusplus <= 201402L
throw (int) // { dg-warning "deprecated" "" { target { ! c++1z } } }
#endif
;
};
C <D, B <D>> c;
......@@ -9,9 +9,9 @@ template<int M, int N> struct pair
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 }
}
};
......@@ -22,5 +22,5 @@ int bar ()
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 {};
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(); };
......
......@@ -87,8 +87,16 @@ struct Y
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 ()
{
......@@ -112,7 +120,10 @@ template <typename T> T *X<T>::operator -> () const
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> ();
}
......@@ -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 ();
}
......
......@@ -12,7 +12,13 @@ void my_terminate ()
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) { }
......
......@@ -12,7 +12,13 @@ void operator delete (void *) throw ()
}
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 {
......@@ -20,7 +26,13 @@ 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 ()
......
......@@ -15,7 +15,13 @@ class A<int, int>
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;
......@@ -26,7 +32,13 @@ class A<void *, void *>
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.
......
......@@ -38,7 +38,10 @@ force_unwind ()
}
static void
doit () throw(int)
doit ()
#if __cplusplus <= 201402L
throw(int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
#endif
{
force_unwind ();
}
......
......@@ -8,18 +8,36 @@ template <class _Tp> class AutoPtr
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; }
......
......@@ -2,7 +2,11 @@
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)));
};
......
......@@ -15,7 +15,10 @@ void f1()
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();
}
......@@ -13,14 +13,14 @@ struct D : private B
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)
......
......@@ -3,8 +3,15 @@
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 }
......@@ -12,7 +12,10 @@ struct A : virtual public Base
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();
}
......
......@@ -8,12 +8,20 @@ struct 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 "" }
......
......@@ -19,7 +19,11 @@ struct D : public B {
} 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
......
......@@ -4,7 +4,10 @@
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;
}
......
......@@ -17,7 +17,11 @@ struct C
{
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>
......@@ -23,7 +23,7 @@ handle_unexpected ()
}
static void
doit () throw (Two)
doit () throw (Two) // { dg-warning "deprecated" "" { target { c++11 } } }
{
throw One ();
}
......
......@@ -15,6 +15,12 @@ struct B
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; }
......@@ -22,43 +28,43 @@ struct D
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; }
};
......
......@@ -12,6 +12,12 @@ struct B
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 { };
......@@ -22,12 +28,12 @@ struct D
struct E
{
E() throw(int) { }
E() THROW_INT { }
};
struct E1
{
E1() throw(int) { throw int(); }
E1() THROW_INT { throw int(); }
};
struct F
......@@ -37,7 +43,7 @@ struct F
struct G
{
G(const G&) throw(int) { throw int(); }
G(const G&) THROW_INT { throw int(); }
};
template<typename T>
......
......@@ -15,6 +15,12 @@ struct B
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() { }
......@@ -22,12 +28,12 @@ struct D
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
......@@ -37,28 +43,28 @@ 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() { }
};
......
......@@ -2,8 +2,21 @@
// { 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 ()
{
......
......@@ -4,7 +4,11 @@
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 ()
......
......@@ -4,7 +4,11 @@
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 ()
......
......@@ -3,7 +3,11 @@
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 ()
......
......@@ -3,7 +3,11 @@
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 ()
......
......@@ -7,7 +7,10 @@
struct foo
{
foo () throw (int)
foo ()
#if __cplusplus <= 201402L
throw (int) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } }
#endif
{ /* count (-) */
throw (1);
}
......
......@@ -6,6 +6,6 @@
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;
......@@ -5,7 +5,11 @@ class C
{
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" }
};
......
......@@ -11,8 +11,16 @@ namespace ns
{
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;
};
......@@ -20,11 +28,19 @@ namespace ns
// 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 )
{
}
......
......@@ -58,16 +58,34 @@ struct Egeneric {
};
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 "" "" }
......@@ -5,6 +5,9 @@ class A {};
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 }
......@@ -1667,8 +1667,16 @@ namespace std
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)
......
......@@ -4,7 +4,10 @@
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;
......
......@@ -21,9 +21,16 @@ public:
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();
......
......@@ -19,12 +19,24 @@ namespace std {
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 {
......@@ -33,7 +45,10 @@ extern "C" {
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;
......
......@@ -27,7 +27,10 @@ struct A : virtual public Base
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;
......
......@@ -21,7 +21,10 @@ struct B {};
__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;
......
......@@ -21,7 +21,10 @@ struct A : virtual public Base
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;
......
......@@ -22,7 +22,10 @@ struct B {};
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;
......
......@@ -28,7 +28,10 @@ struct B {};
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;
......
......@@ -21,7 +21,10 @@ struct B {};
__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;
......
......@@ -28,7 +28,10 @@ struct A : virtual public Base
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;
......
......@@ -29,7 +29,10 @@ struct A : virtual public Base
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;
......
......@@ -15,7 +15,11 @@ struct D : public B {
} 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;
};
};
......
......@@ -3,7 +3,10 @@
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;
}
......
......@@ -93,19 +93,28 @@ extern "C" void *realloc (void *p, size_t size)
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){
......
......@@ -18,11 +18,18 @@ static int thrower ()
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;}
......@@ -30,10 +37,17 @@ X::~X () throw ()
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.
......@@ -9,7 +9,7 @@ void my_term () { exit (1); }
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.
......@@ -9,7 +9,7 @@ void my_term () { exit (1); }
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.
......@@ -9,7 +9,7 @@ void my_term () { exit (1); }
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.
......@@ -9,7 +9,7 @@ void my_term () { exit (0); }
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;
}
......
......@@ -4,7 +4,10 @@
#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;
}
......
......@@ -3,9 +3,16 @@
// 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 } }
};
......@@ -10,7 +10,13 @@ void my_terminate() {
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>
......@@ -7,7 +8,7 @@ void my_unexpected() {
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>
......@@ -7,7 +8,7 @@ void my_unexpected() {
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>
......@@ -7,7 +8,7 @@ void my_unexpected() {
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);
......
......@@ -9,7 +9,7 @@ void my_terminate_handler() {
}
void throw_an_unexpected_exception() throw() {
throw 1;
throw 1; // { dg-warning "throw will always call terminate" "" { target c++1z } }
}
int main() {
......
......@@ -5,5 +5,9 @@
class not_ok {
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
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
}
......@@ -8,7 +8,7 @@ struct foo
};
void foo::x() throw(bar) // { dg-error "" } parse error
{
{ // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } .-1 }
}
void bar()
......
......@@ -13,7 +13,10 @@ struct X {
{
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 } }
......@@ -2,7 +2,10 @@
// { 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 { }
......
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