This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR c++/27508: ICE on invalid destructor name
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 09 May 2006 14:39:53 +0200 (CEST)
- Subject: [patch] Fix PR c++/27508: ICE on invalid destructor name
The C++ frontend ICEs on the following code snippet:
struct A;
using ::~A;
bug.cc:2: internal compiler error: tree check: expected class 'type', have 'declaration' (namespace_decl) in check_dtor_name, at cp/call.c:239
Please submit a full bug report, [etc.]
The patch fixes that by rejecting NAMESPACE_DECLs as basetypes in
check_dtor_name.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline, 4.1 branch, and 4.0 branch?
Regards,
Volker
:ADDPATCH C++:
2006-05-09 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27508
* call.c (check_dtor_name): Emit error if basetype is a NAMESPACE_DECL.
===================================================================
--- gcc/gcc/cp/call.c 2006-05-08 22:06:29 +0200
+++ gcc/gcc/cp/call.c 2006-05-08 22:06:41 +0200
@@ -208,6 +208,12 @@ check_dtor_name (tree basetype, tree nam
if (name == error_mark_node)
return true;
+ if (TREE_CODE (basetype) == NAMESPACE_DECL)
+ {
+ error ("%qT is not a class-name", basetype);
+ return false;
+ }
+
if (TREE_CODE (name) == TYPE_DECL)
name = TREE_TYPE (name);
else if (TYPE_P (name))
===================================================================
2006-05-09 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27508
* g++.dg/lookup/dtor1.C: New test.
===================================================================
--- gcc/gcc/testsuite/g++.dg/lookup/dtor1.C 2003-09-23 19:59:22 +0200
+++ gcc/gcc/testsuite/g++.dg/lookup/dtor1.C 2006-05-08 22:11:44 +0200
@@ -0,0 +1,5 @@
+// PR c++/27508
+// { dg-do compile }
+
+struct A;
+using ::~A; // { dg-error "class-name|member" }
===================================================================