From: Jason Merrill Date: Mon, 4 Aug 2008 18:39:16 +0000 (-0400) Subject: re PR c++/37006 (explicitly deleted inline function gives warning "used but never... X-Git-Tag: releases/gcc-4.4.0~3394 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b26c96e339b9e546ffe5ac2a114af397bf4cd17;p=thirdparty%2Fgcc.git re PR c++/37006 (explicitly deleted inline function gives warning "used but never defined") PR c++/37006 * pt.c (tsubst_decl): Leave DECL_INITIAL set on deleted instantiations. From-SVN: r138648 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c40b9894e435..1918189a11b5 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 04fd29bb0092..6e4f0ba447b3 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 000000000000..efde415936d3 --- /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" } +}