This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to throw specs on pointers
- To: gcc-patches at gcc dot gnu dot org
- Subject: C++ PATCH to throw specs on pointers
- From: Jason Merrill <jason at redhat dot com>
- Date: 17 Feb 2001 23:53:28 +0000
Fixes g++.eh/spec7.C, below.
Checked in on trunk and branch, as the init.c hunk fixes a bug I introduced
recently.
2001-02-17 Jason Merrill <jason@redhat.com>
* decl.c (bad_specifiers): Allow throw specs on things with
pointer-to-function or -member-function type.
* init.c (build_default_init): Don't use a CONSTRUCTOR to initialize
a pmf.
*** decl.c.~1~ Sat Feb 17 00:16:19 2001
--- decl.c Sat Feb 17 23:31:09 2001
*************** bad_specifiers (object, type, virtualp,
*** 8638,8644 ****
object, type);
if (friendp)
cp_error_at ("`%D' declared as a friend", object);
! if (raises)
cp_error_at ("`%D' declared with an exception specification", object);
}
--- 8638,8645 ----
object, type);
if (friendp)
cp_error_at ("`%D' declared as a friend", object);
! if (raises && !TYPE_PTRFN_P (TREE_TYPE (object))
! && !TYPE_PTRMEMFUNC_P (TREE_TYPE (object)))
cp_error_at ("`%D' declared with an exception specification", object);
}
*** init.c.~1~ Fri Feb 16 16:34:08 2001
--- init.c Sat Feb 17 23:31:09 2001
*************** build_default_init (type)
*** 218,224 ****
anything with a CONSTRUCTOR for arrays here, as that would imply
copy-initialization. */
return NULL_TREE;
! else if (AGGREGATE_TYPE_P (type))
{
/* This is a default initialization of an aggregate, but not one of
non-POD class type. We cleverly notice that the initialization
--- 218,224 ----
anything with a CONSTRUCTOR for arrays here, as that would imply
copy-initialization. */
return NULL_TREE;
! else if (AGGREGATE_TYPE_P (type) && !TYPE_PTRMEMFUNC_P (type))
{
/* This is a default initialization of an aggregate, but not one of
non-POD class type. We cleverly notice that the initialization
// Test that we allow simple throw specs on pointers.
void f() throw () { }
void (*pf)() throw () = f;
struct A
{
void g() throw () { }
static void (A::*pmf)() throw ();
};
void (A::* A::pmf)() = &A::g;
int main()
{
pf ();
A a;
(a.*A::pmf)();
}