aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-01-05 12:52:18 -0500
committerJason Merrill <jason@gcc.gnu.org>2009-01-05 12:52:18 -0500
commit8adee3e6f0a1205bc2bd44cf96dcb4f5e5317016 (patch)
tree8ce278d044fc48c0bc7640f98c1d80db9ba67d08 /gcc
parent48a01864c6f06f25670ad95ada8181d841fab26e (diff)
downloadgcc-8adee3e6f0a1205bc2bd44cf96dcb4f5e5317016.zip
gcc-8adee3e6f0a1205bc2bd44cf96dcb4f5e5317016.tar.gz
gcc-8adee3e6f0a1205bc2bd44cf96dcb4f5e5317016.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/class.c3
-rw-r--r--gcc/cp/decl.c5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/defaulted7.C12
5 files changed, 32 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7ffa760..7c5ae83 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 805e513..8d326f2 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 76482d2..2e19fb3 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d70fac7..38a3105 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted7.C b/gcc/testsuite/g++.dg/cpp0x/defaulted7.C
new file mode 100644
index 0000000..97c2925
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/defaulted7.C
@@ -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" }