re PR c++/38701 (ICE with defaulted function)

PR c++/38701
        * decl.c (cp_finish_decl): Clear DECL_INITIAL for invalid
        defaulting.

        PR c++/38702
        * class.c (defaultable_fn_p): Only operator== can be a copy
        assignment operator.

From-SVN: r143081
This commit is contained in:
Jason Merrill 2009-01-05 12:52:18 -05:00 committed by Jason Merrill
parent 48a01864c6
commit 8adee3e6f0
5 changed files with 32 additions and 2 deletions

View file

@ -1,3 +1,13 @@
2009-01-05 Jason Merrill <jason@redhat.com>
PR c++/38701
* decl.c (cp_finish_decl): Clear DECL_INITIAL for invalid
defaulting.
PR c++/38702
* class.c (defaultable_fn_p): Only operator== can be a copy
assignment operator.
2009-01-02 Jason Merrill <jason@redhat.com>
PR c++/38698

View file

@ -4147,7 +4147,8 @@ defaultable_fn_p (tree fn)
}
else if (DECL_DESTRUCTOR_P (fn))
return true;
else if (DECL_ASSIGNMENT_OPERATOR_P (fn))
else if (DECL_ASSIGNMENT_OPERATOR_P (fn)
&& DECL_OVERLOADED_OPERATOR_P (fn) == NOP_EXPR)
return copy_fn_p (fn);
else
return false;

View file

@ -5517,7 +5517,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
else if (init == ridpointers[(int)RID_DEFAULT])
{
if (!defaultable_fn_p (decl))
error ("%qD cannot be defaulted", decl);
{
error ("%qD cannot be defaulted", decl);
DECL_INITIAL (decl) = NULL_TREE;
}
else
DECL_DEFAULTED_FN (decl) = 1;
}

View file

@ -1,3 +1,7 @@
2009-01-05 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/defaulted7.C: New test.
2009-01-05 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/38672

View file

@ -0,0 +1,12 @@
// PR c++/38701, 38702
// { dg-options "-std=c++0x" }
void foo() = default; // { dg-error "cannot be defaulted" }
namespace
{
void bar() = default; // { dg-error "cannot be defaulted" }
}
enum E { e };
E& operator |= (E&, const E&) = default; // { dg-error "cannot be defaulted" }