OSDN Git Service

PR c++/39225
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Feb 2009 05:32:40 +0000 (05:32 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Feb 2009 05:32:40 +0000 (05:32 +0000)
        * decl.c (grokdeclarator): Handle ~identifier.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144314 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 00ac24e..ecc83b4 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/39225
+       * decl.c (grokdeclarator): Handle ~identifier.
+
 2009-02-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/39175
index 930f944..551764d 100644 (file)
@@ -7659,7 +7659,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;
@@ -8161,8 +8163,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:
@@ -9038,21 +9041,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 7a5f58e..e84cac9 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  Kazu Hirata  <kazu@codesourcery.com>
 
        * gcc.c-torture/execute/20090219-1.c: New.
@@ -68,6 +73,9 @@
 
 2009-02-18  Jason Merrill  <jason@redhat.com>
 
+       PR c++/38880
+       * g++.dg/init/const7.C: Remove XFAIL.
+
        PR target/39179
        * g++.dg/opt/const6.C: New test.
 
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;
+}