diff options
author | Jason Merrill <jason@redhat.com> | 2010-06-16 11:45:22 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-06-16 11:45:22 -0400 |
commit | 7c69566f11b2361bcfac2c53e385a271792d09f2 (patch) | |
tree | 7c7392e8a65a79e5d3162bb84ba287ea4f5f1339 | |
parent | 33766b66e131cbab54238cbecb8b8c669565deff (diff) | |
download | gcc-7c69566f11b2361bcfac2c53e385a271792d09f2.zip gcc-7c69566f11b2361bcfac2c53e385a271792d09f2.tar.gz gcc-7c69566f11b2361bcfac2c53e385a271792d09f2.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/method.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/noexcept01.C | 8 |
4 files changed, 26 insertions, 0 deletions
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 <jason@redhat.com> + + * method.c (defaulted_late_check): Give the defaulted method + the same exception specification as the implicit declaration. + 2010-06-15 Jason Merrill <jason@redhat.com> * 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 <jason@redhat.com> + + * g++.dg/cpp0x/noexcept01.C: Test defaulted fns. + 2010-06-16 Richard Guenther <rguenther@suse.de> 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 <class T, bool b> void tf() { |