From 7c69566f11b2361bcfac2c53e385a271792d09f2 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 16 Jun 2010 11:45:22 -0400 Subject: method.c (defaulted_late_check): Give the defaulted method the same exception specification as the implicit... * method.c (defaulted_late_check): Give the defaulted method the same exception specification as the implicit declaration. From-SVN: r160841 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/method.c | 9 +++++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/noexcept01.C | 8 ++++++++ 4 files changed, 26 insertions(+) (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 34593ad..37a3544 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2010-06-16 Jason Merrill + + * method.c (defaulted_late_check): Give the defaulted method + the same exception specification as the implicit declaration. + 2010-06-15 Jason Merrill * class.c (add_implicitly_declared_members): Implicit assignment diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 97f3566..0400277 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1022,6 +1022,15 @@ defaulted_late_check (tree fn) error_at (DECL_SOURCE_LOCATION (fn), "does not match expected signature %qD", implicit_fn); } + + /* 8.4.2/2: If it is explicitly defaulted on its first declaration, it is + implicitly considered to have the same exception-specification as if + it had been implicitly declared. */ + if (DECL_DEFAULTED_IN_CLASS_P (fn)) + { + tree eh_spec = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (implicit_fn)); + TREE_TYPE (fn) = build_exception_variant (TREE_TYPE (fn), eh_spec); + } } /* Returns true iff FN can be explicitly defaulted, and gives any diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e58ee40..b06e381 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-06-16 Jason Merrill + + * g++.dg/cpp0x/noexcept01.C: Test defaulted fns. + 2010-06-16 Richard Guenther PR c/44555 diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept01.C b/gcc/testsuite/g++.dg/cpp0x/noexcept01.C index e3341d8..f314684 100644 --- a/gcc/testsuite/g++.dg/cpp0x/noexcept01.C +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept01.C @@ -59,6 +59,14 @@ struct F SA (noexcept (F())); +struct G +{ + G() = default; + ~G() = default; +}; + +SA (noexcept (G())); + template void tf() { -- cgit v1.1