* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143081
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
}
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;
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
--- /dev/null
+// 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" }