Commit 8adee3e6 by Jason Merrill Committed by Jason Merrill

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
parent 48a01864
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
......
......@@ -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;
......
......@@ -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;
}
......
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
......
// 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" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment