diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c40b9894e43..1918189a11b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-08-04 Jason Merrill + + PR c++/37006 + * pt.c (tsubst_decl): Leave DECL_INITIAL set on deleted + instantiations. + 2008-08-04 Simon Baldwin PR c++/36999 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 04fd29bb009..6e4f0ba447b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8143,7 +8143,9 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) /* Clear out the mangled name and RTL for the instantiation. */ SET_DECL_ASSEMBLER_NAME (r, NULL_TREE); SET_DECL_RTL (r, NULL_RTX); - DECL_INITIAL (r) = NULL_TREE; + /* Leave DECL_INITIAL set on deleted instantiations. */ + if (!DECL_DELETED_FN (r)) + DECL_INITIAL (r) = NULL_TREE; DECL_CONTEXT (r) = ctx; if (member && DECL_CONV_FN_P (r)) diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted3.C b/gcc/testsuite/g++.dg/cpp0x/defaulted3.C new file mode 100644 index 00000000000..efde415936d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted3.C @@ -0,0 +1,16 @@ +// PR c++/37006 +// { dg-options "-std=c++0x" } + +template +struct A { + template + bool operator==(const A&) = delete; // { dg-error "deleted function" } + operator bool () { return true; } +}; + +int main() +{ + A a1; + A a2; + if(a1 == a2) {} // { dg-error "used here" } +}