Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-04-01 Thread Jason Merrill
On 03/30/2012 09:34 PM, Paolo Carlini wrote: Thus I'm adding a !TYPE_BEING_DEFINED (DECL_CONTEXT (decl)) check Sounds good. we reject, with a different exception specifier error, both: templatetypename T struct A { ~A() noexcept; }; templatetypename T AT::~A() { } and: templatetypename

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-04-01 Thread Paolo Carlini
Hi, we reject, with a different exception specifier error, both: templatetypename T struct A { ~A() noexcept; }; templatetypename T AT::~A() { } and: templatetypename T struct A { ~A(); }; templatetypename T AT::~A() noexcept { } Over the last days I wasted a lot of time trying

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-30 Thread Paolo Carlini
Hi again, On 03/30/2012 12:26 AM, Paolo Carlini wrote: On 03/29/2012 09:27 PM, Jason Merrill wrote: On 03/29/2012 03:06 PM, Paolo Carlini wrote: The exception specification on old_decl doesn't matter; we can drop that test. I seem to remember something going wrong with templates otherwise,

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-29 Thread Paolo Carlini
... attached the testsuite changes I have so far (seem all rather straightforward to me). Thanks, Paolo. Index: testsuite/g++.old-deja/g++.eh/cleanup1.C === --- testsuite/g++.old-deja/g++.eh/cleanup1.C

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-29 Thread Jason Merrill
On 03/28/2012 06:40 PM, Paolo Carlini wrote: + /* 12.4/3 */ + if (cxx_dialect= cxx0x + DECL_DESTRUCTOR_P (decl) + TYPE_RAISES_EXCEPTIONS (TREE_TYPE (old_decl))) + deduce_noexcept_on_destructor (decl); The exception specification on old_decl

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-29 Thread Paolo Carlini
Hi, On 03/28/2012 06:40 PM, Paolo Carlini wrote: + /* 12.4/3 */ + if (cxx_dialect= cxx0x + DECL_DESTRUCTOR_P (decl) + TYPE_RAISES_EXCEPTIONS (TREE_TYPE (old_decl))) +deduce_noexcept_on_destructor (decl); The exception specification on old_decl doesn't matter; we can drop

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-29 Thread Paolo Carlini
Hi, On 03/28/2012 06:40 PM, Paolo Carlini wrote: + /* 12.4/3 */ + if (cxx_dialect= cxx0x + DECL_DESTRUCTOR_P (decl) + TYPE_RAISES_EXCEPTIONS (TREE_TYPE (old_decl))) +deduce_noexcept_on_destructor (decl); The exception specification on old_decl doesn't matter; we can drop

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-29 Thread Jason Merrill
On 03/29/2012 03:06 PM, Paolo Carlini wrote: The exception specification on old_decl doesn't matter; we can drop that test. I seem to remember something going wrong with templates otherwise, because implicitly_declare_fn has gcc_assert (!dependent_type_p (type)); We shouldn't be doing this

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-29 Thread Paolo Carlini
On 03/29/2012 09:27 PM, Jason Merrill wrote: On 03/29/2012 03:06 PM, Paolo Carlini wrote: The exception specification on old_decl doesn't matter; we can drop that test. I seem to remember something going wrong with templates otherwise, because implicitly_declare_fn has gcc_assert

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-29 Thread Paolo Carlini
On 03/29/2012 09:27 PM, Jason Merrill wrote: On 03/29/2012 03:06 PM, Paolo Carlini wrote: The exception specification on old_decl doesn't matter; we can drop that test. I seem to remember something going wrong with templates otherwise, because implicitly_declare_fn has gcc_assert

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-28 Thread Paolo Carlini
Hi again, On 03/26/2012 09:31 PM, Jason Merrill wrote: On 03/26/2012 07:22 AM, Paolo Carlini wrote: My basic idea so far is very simple: --- class.c (revision 185792) +++ class.c (working copy) @@ -1001,6 +1001,10 @@ add_method (tree type, tree method, tree using_dec destructor, type); } +

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-28 Thread Jason Merrill
On 03/28/2012 11:02 AM, Paolo Carlini wrote: + !comp_except_specs (new_exceptions, old_exceptions, ce_normal) + /* Special case in C++11: noexcept has been deduced as true for +the declaration and there is no exception-specification on the +definition. */ +

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-28 Thread Paolo Carlini
Hi, On 03/28/2012 11:02 AM, Paolo Carlini wrote: + !comp_except_specs (new_exceptions, old_exceptions, ce_normal) + /* Special case in C++11: noexcept has been deduced as true for + the declaration and there is no exception-specification on the + definition. */ +

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-28 Thread Paolo Carlini
Oops... 1- Turns out the check_bases_and_members change has to happen earlier, because we want to fixup the exceptions before check_bases, otherwise we reject things like (in the C++ library and elsewhere): struct True2 { virtual ~True2() noexcept; }; template typename Base struct C : Base {

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-26 Thread Jason Merrill
On 03/26/2012 07:22 AM, Paolo Carlini wrote: My basic idea so far is very simple: --- class.c (revision 185792) +++ class.c (working copy) @@ -1001,6 +1001,10 @@ add_method (tree type, tree method, tree using_dec destructor, type); } + else if (cxx_dialect = cxx0x + !TYPE_RAISES_EXCEPTIONS

Re: [C++ RFC / Patch] Implementing Deducing noexcept for destructors

2012-03-26 Thread Paolo Carlini
On 03/26/2012 09:31 PM, Jason Merrill wrote: On 03/26/2012 07:22 AM, Paolo Carlini wrote: My basic idea so far is very simple: --- class.c (revision 185792) +++ class.c (working copy) @@ -1001,6 +1001,10 @@ add_method (tree type, tree method, tree using_dec destructor, type); } + else if