aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2013-05-25 08:39:44 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2013-05-25 08:39:44 +0000
commita544998ee31436a079b74ff6e29c5d4ade7b6ba7 (patch)
tree9480d8ea22c7e40e507af3c9e5b55470fc05371f
parenta62e8b4a2a10dccc6cd7760ca48b57c297495863 (diff)
downloadgcc-a544998ee31436a079b74ff6e29c5d4ade7b6ba7.zip
gcc-a544998ee31436a079b74ff6e29c5d4ade7b6ba7.tar.gz
gcc-a544998ee31436a079b74ff6e29c5d4ade7b6ba7.tar.bz2
re PR c++/25666 (Bad diagnostic for templated destructor as friend)
/cp 2013-05-25 Paolo Carlini <paolo.carlini@oracle.com> PR c++/25666 * decl2.c (check_classfn): Check for destructors declared as member templates. /testsuite 2013-05-25 Paolo Carlini <paolo.carlini@oracle.com> PR c++/25666 * g++.dg/parse/dtor16.C: New. * g++.dg/parse/dtor6.C: Adjust. From-SVN: r199324
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c9
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/parse/dtor16.C8
-rw-r--r--gcc/testsuite/g++.dg/parse/dtor6.C4
5 files changed, 31 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4d13955..ed1d479 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2013-05-25 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/25666
+ * decl2.c (check_classfn): Check for destructors declared as member
+ templates.
+
2013-05-24 Jason Merrill <jason@redhat.com>
PR c++/56971
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 358a26f..8119210 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -646,6 +646,15 @@ check_classfn (tree ctype, tree function, tree template_parms)
/* 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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a0278d5..e0d4ccf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2013-05-25 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/25666
+ * g++.dg/parse/dtor16.C: New.
+ * g++.dg/parse/dtor6.C: Adjust.
+
2013-05-24 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/19618
diff --git a/gcc/testsuite/g++.dg/parse/dtor16.C b/gcc/testsuite/g++.dg/parse/dtor16.C
new file mode 100644
index 0000000..ff445c3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/dtor16.C
@@ -0,0 +1,8 @@
+// PR c++/25666
+
+struct A { ~A(); };
+
+struct B
+{
+ template<int> friend A::~A(); // { dg-error "member template" }
+};
diff --git a/gcc/testsuite/g++.dg/parse/dtor6.C b/gcc/testsuite/g++.dg/parse/dtor6.C
index 3333161..86370d5 100644
--- a/gcc/testsuite/g++.dg/parse/dtor6.C
+++ b/gcc/testsuite/g++.dg/parse/dtor6.C
@@ -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" }
};