This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix PR/10926
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 17 Jun 2003 13:10:44 +0200
- Subject: [C++ PATCH] Fix PR/10926
Hello,
we are incorrectly accepting template destructors, which are forbidden by
the standard. This causes problems/ICE later (eg. in build_delete). This
patch checks for it and rejects such declarations.
Tested on i686-pc-cygwin, with a bootstrap for c, c++, and java, and a
top-level "make check-g++" with no new regressions.
OK for mainline?
Giovanni Bajo
2003-06-17 Giovanni Bajo <giovannibajo@libero.it>
PR c++/10926
* decl.c (grokfndecl): Add a test to reject destructors declared
as templates.
2003-06-17 Giovanni Bajo <giovannibajo@libero.it>
PR c++/10926
* g++.dg/parse/dtor2.C: New test.
Index: decl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1059
diff -c -w -r1.1059 decl.c
*** decl.c 31 May 2003 12:53:41 -0000 1.1059
--- decl.c 17 Jun 2003 03:10:36 -0000
***************
*** 9048,9053 ****
--- 9048,9059 ----
if (DECL_CONSTRUCTOR_P (decl) && !grok_ctor_properties (ctype, decl))
return NULL_TREE;
+ if (DECL_DESTRUCTOR_P (decl) && template_parm_scope_p())
+ {
+ error ("a destructor may not be declared as a template");
+ return NULL_TREE;
+ }
+
if (ctype == NULL_TREE || check)
return decl;
// { dg-do compile }
// Origin: xue weizhong <xueweizhong at mail dot zte dot com dot cn>
// PR c++/10926: ICE in build_delete when trying to declare template
destructor
struct Foo
{
template <class T> ~Foo(); // { dg-error "destructor" "" }
};