This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/39225 (ICE on ~identifier)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 20 Feb 2009 00:31:55 -0500
- Subject: C++ PATCH for c++/39225 (ICE on ~identifier)
More fallout from my ~identifier patch. But now we give a better error
message for this testcase.
Tested x86_64-pc-linux-gnu, applied to trunk.
2009-02-20 Jason Merrill <jason@redhat.com>
PR c++/39225
* decl.c (grokdeclarator): Handle ~identifier.
Index: cp/decl.c
===================================================================
*** cp/decl.c (revision 144313)
--- cp/decl.c (working copy)
*************** grokdeclarator (const cp_declarator *dec
*** 7659,7665 ****
}
type = TREE_OPERAND (decl, 0);
! name = IDENTIFIER_POINTER (constructor_name (type));
dname = decl;
}
break;
--- 7659,7667 ----
}
type = TREE_OPERAND (decl, 0);
! if (TYPE_P (type))
! type = constructor_name (type);
! name = IDENTIFIER_POINTER (type);
dname = decl;
}
break;
*************** grokdeclarator (const cp_declarator *dec
*** 8161,8168 ****
switch (TREE_CODE (unqualified_id))
{
case BIT_NOT_EXPR:
! unqualified_id
! = constructor_name (TREE_OPERAND (unqualified_id, 0));
break;
case IDENTIFIER_NODE:
--- 8163,8171 ----
switch (TREE_CODE (unqualified_id))
{
case BIT_NOT_EXPR:
! unqualified_id = TREE_OPERAND (unqualified_id, 0);
! if (TYPE_P (unqualified_id))
! unqualified_id = constructor_name (unqualified_id);
break;
case IDENTIFIER_NODE:
*************** grokdeclarator (const cp_declarator *dec
*** 9038,9058 ****
/* Check that the name used for a destructor makes sense. */
if (sfk == sfk_destructor)
{
if (!ctype)
{
gcc_assert (friendp);
error ("expected qualified name in friend declaration "
! "for destructor %qD",
! id_declarator->u.id.unqualified_name);
return error_mark_node;
}
! if (!same_type_p (TREE_OPERAND
! (id_declarator->u.id.unqualified_name, 0),
! ctype))
{
error ("declaration of %qD as member of %qT",
! id_declarator->u.id.unqualified_name, ctype);
return error_mark_node;
}
}
--- 9041,9060 ----
/* Check that the name used for a destructor makes sense. */
if (sfk == sfk_destructor)
{
+ tree uqname = id_declarator->u.id.unqualified_name;
+
if (!ctype)
{
gcc_assert (friendp);
error ("expected qualified name in friend declaration "
! "for destructor %qD", uqname);
return error_mark_node;
}
! if (!check_dtor_name (ctype, TREE_OPERAND (uqname, 0)))
{
error ("declaration of %qD as member of %qT",
! uqname, ctype);
return error_mark_node;
}
}
Index: testsuite/g++.dg/parse/dtor15.C
===================================================================
*** testsuite/g++.dg/parse/dtor15.C (revision 0)
--- testsuite/g++.dg/parse/dtor15.C (revision 0)
***************
*** 0 ****
--- 1,16 ----
+ // PR c++/39225
+
+ template <class T>
+ class A
+ {
+ public:
+ A() {}
+ ~B() {} // { dg-error "~B" }
+ };
+
+ int main()
+ {
+ A<int> *a = new A<int>;
+
+ return 0;
+ }