Hi,
this remained assigned to me way too much time. The story goes that we
used to ICE on parse/dtor6.C, then Mark fixed the ICE, and Volker opened
25666 as a purely diagnostic issue, that is about the lack of a terse
error message mentioning that templated destructors are illegal. Turns
out we do already have such kind of diagnostics, but only in
push_template_decl_real: in this case do_friend calls instead
check_classfn which doesn't, thus ends up producing the more verbose
generic diagnostics.
Tested x86_64-linux.
Thanks,
Paolo.
/////////////////////////////
/cp
2013-05-24 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/25666
* decl2.c (check_classfn): Check for destructors declared as member
templates.
/testsuite
2013-05-24 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/25666
* g++.dg/parse/dtor16.C: New.
* g++.dg/parse/dtor6.C: Adjust.
Index: cp/decl2.c
===================================================================
--- cp/decl2.c (revision 199313)
+++ cp/decl2.c (working copy)
@@ -646,6 +646,15 @@ check_classfn (tree ctype, tree function, tree tem
/* OK, is this a definition of a member template? */
is_template = (template_parms != NULL_TREE);
+ /* [temp.mem]
+
+ A destructor shall not be a member template. */
+ if (DECL_DESTRUCTOR_P (function) && is_template)
+ {
+ error ("destructor %qD declared as member template", function);
+ return error_mark_node;
+ }
+
/* We must enter the scope here, because conversion operators are
named by target type, and type equivalence relies on typenames
resolving within the scope of CTYPE. */
Index: testsuite/g++.dg/parse/dtor16.C
===================================================================
--- testsuite/g++.dg/parse/dtor16.C (revision 0)
+++ testsuite/g++.dg/parse/dtor16.C (working copy)
@@ -0,0 +1,8 @@
+// PR c++/25666
+
+struct A { ~A(); };
+
+struct B
+{
+ template<int> friend A::~A(); // { dg-error "member template" }
+};
Index: testsuite/g++.dg/parse/dtor6.C
===================================================================
--- testsuite/g++.dg/parse/dtor6.C (revision 199313)
+++ testsuite/g++.dg/parse/dtor6.C (working copy)
@@ -1,8 +1,8 @@
// PR c++/25638
-struct A { ~A(); }; // { dg-error "candidate" }
+struct A { ~A(); };
struct B : A
{
- template<int> friend A::~A(); // { dg-error "match" }
+ template<int> friend A::~A(); // { dg-error "member template" }
};