decl2.c (build_artificial_parm): Set TREE_READONLY.

* decl2.c (build_artificial_parm): Set TREE_READONLY.

        * 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.

From-SVN: r39810
This commit is contained in:
Jason Merrill 2001-02-17 19:00:29 -05:00 committed by Jason Merrill
parent 8084b91ec4
commit a714e5c5d3
5 changed files with 34 additions and 2 deletions

View File

@ -1,3 +1,12 @@
2001-02-17 Jason Merrill <jason@redhat.com>
* decl2.c (build_artificial_parm): Set TREE_READONLY.
* 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.
2001-02-17 Mark Mitchell <mark@codesourcery.com>
* call.c (check_dtor_name): Handle template names correctly.

View File

@ -8638,7 +8638,8 @@ bad_specifiers (object, type, virtualp, quals, inlinep, friendp, raises)
object, type);
if (friendp)
cp_error_at ("`%D' declared as a friend", object);
if (raises)
if (raises && !TYPE_PTRFN_P (TREE_TYPE (object))
&& !TYPE_PTRMEMFUNC_P (TREE_TYPE (object)))
cp_error_at ("`%D' declared with an exception specification", object);
}

View File

@ -917,6 +917,9 @@ build_artificial_parm (name, type)
parm = build_decl (PARM_DECL, name, type);
DECL_ARTIFICIAL (parm) = 1;
/* All our artificial parms are implicitly `const'; they cannot be
assigned to. */
TREE_READONLY (parm) = 1;
DECL_ARG_TYPE (parm) = type;
return parm;
}

View File

@ -218,7 +218,7 @@ build_default_init (type)
anything with a CONSTRUCTOR for arrays here, as that would imply
copy-initialization. */
return NULL_TREE;
else if (AGGREGATE_TYPE_P (type))
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

View File

@ -0,0 +1,19 @@
// 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)();
}