]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/37006 (explicitly deleted inline function gives warning "used but never...
authorJason Merrill <jason@redhat.com>
Mon, 4 Aug 2008 18:39:16 +0000 (14:39 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 4 Aug 2008 18:39:16 +0000 (14:39 -0400)
        PR c++/37006
        * pt.c (tsubst_decl): Leave DECL_INITIAL set on deleted
        instantiations.

From-SVN: r138648

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/defaulted3.C [new file with mode: 0644]

index c40b9894e4351b4734c8ee8664081ca0bd3e3cc6..1918189a11b5bb2360666aca4276db320f6a69db 100644 (file)
@@ -1,3 +1,9 @@
+2008-08-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/37006
+       * pt.c (tsubst_decl): Leave DECL_INITIAL set on deleted
+       instantiations.
+
 2008-08-04  Simon Baldwin  <simonb@google.com>
 
        PR c++/36999
index 04fd29bb0092e3f4b710805de7418268ebe6c130..6e4f0ba447b36357b22e05ca70b71853008b5d56 100644 (file)
@@ -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 (file)
index 0000000..efde415
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/37006
+// { dg-options "-std=c++0x" }
+
+template<class T>
+struct A {
+  template<class U>
+  bool operator==(const A<U>&) = delete; // { dg-error "deleted function" }
+  operator bool () { return true; }
+};
+
+int main()
+{
+  A<int> a1;
+  A<void> a2;
+  if(a1 == a2) {}              // { dg-error "used here" }
+}