]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/39225 (ICE if destructor doen't match class name)
authorJason Merrill <jason@redhat.com>
Fri, 20 Feb 2009 15:21:51 +0000 (10:21 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 20 Feb 2009 15:21:51 +0000 (10:21 -0500)
        PR c++/39225
        * decl.c (grokdeclarator): Handle ~identifier.

From-SVN: r144325

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/dtor15.C [new file with mode: 0644]

index 6b267b9343b16ef01520ffc97fcae1b7da6ca437..e2b4312670884ca39f5653f7cef3a96be04645ae 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/39225
+       * decl.c (grokdeclarator): Handle ~identifier.
+
 2009-02-17  Jason Merrill  <jason@redhat.com>
 
        PR c++/38950
index ea4b49e0db5bad73ef2bd2cebbcea61faab2f395..6a659533ea54323dbf78ff7cbd19c2bf761922e2 100644 (file)
@@ -7512,7 +7512,9 @@ grokdeclarator (const cp_declarator *declarator,
                    }
 
                  type = TREE_OPERAND (decl, 0);
-                 name = IDENTIFIER_POINTER (constructor_name (type));
+                 if (TYPE_P (type))
+                   type = constructor_name (type);
+                 name = IDENTIFIER_POINTER (type);
                  dname = decl;
                }
                break;
@@ -8009,8 +8011,9 @@ grokdeclarator (const cp_declarator *declarator,
       switch (TREE_CODE (unqualified_id))
        {
        case BIT_NOT_EXPR:
-         unqualified_id
-           = constructor_name (TREE_OPERAND (unqualified_id, 0));
+         unqualified_id = TREE_OPERAND (unqualified_id, 0);
+         if (TYPE_P (unqualified_id))
+           unqualified_id = constructor_name (unqualified_id);
          break;
 
        case IDENTIFIER_NODE:
@@ -8856,21 +8859,20 @@ grokdeclarator (const cp_declarator *declarator,
            /* 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",
-                          id_declarator->u.id.unqualified_name);
+                          "for destructor %qD", uqname);
                    return error_mark_node;
                  }
 
-               if (!same_type_p (TREE_OPERAND
-                                 (id_declarator->u.id.unqualified_name, 0),
-                                 ctype))
+               if (!check_dtor_name (ctype, TREE_OPERAND (uqname, 0)))
                  {
                    error ("declaration of %qD as member of %qT",
-                          id_declarator->u.id.unqualified_name, ctype);
+                          uqname, ctype);
                    return error_mark_node;
                  }
              }
index 9d0809dd2a19e4cc15c64c5a15f157ab6f6486bf..d3d01859086da8e15248eb4f77c558b4c88802b7 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/39225
+       * g++.dg/parse/dtor15.C: New test.
+
 2009-02-19  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/39228
diff --git a/gcc/testsuite/g++.dg/parse/dtor15.C b/gcc/testsuite/g++.dg/parse/dtor15.C
new file mode 100644 (file)
index 0000000..ae85a70
--- /dev/null
@@ -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;
+}