]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/13086 (the location of the warning message is wrong when calling delete...
authorGiovanni Bajo <giovannibajo@gcc.gnu.org>
Thu, 5 Feb 2004 13:22:09 +0000 (13:22 +0000)
committerGiovanni Bajo <giovannibajo@gcc.gnu.org>
Thu, 5 Feb 2004 13:22:09 +0000 (13:22 +0000)
PR c++/13086
* init.c (build_delete): Emit a more informative error message in
case of an incomplete type, and on the correct source line.

From-SVN: r77310

gcc/cp/ChangeLog
gcc/cp/init.c

index 8aac4caefada6e73fe13ed9a73fe015feb274861..73f3d766cb8925bb2e09d94526c1e425b87f9e61 100644 (file)
@@ -1,3 +1,9 @@
+2004-02-05  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/13086
+       * init.c (build_delete): Emit a more informative error message in
+       case of an incomplete type, and on the correct source line.
+
 2004-01-30  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
        PR c++/13683
index ba30a9b6177407cda3b3ce28a3a4f4000ab4fcc5..1090f556bc6950699b86a0ce19822ca663821a67 100644 (file)
@@ -3098,23 +3098,35 @@ build_delete (type, addr, auto_delete, flags, use_global_delete)
 
   if (TREE_CODE (type) == POINTER_TYPE)
     {
+      bool complete_p = true;
+
       type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
       if (TREE_CODE (type) == ARRAY_TYPE)
        goto handle_array;
 
-      if (VOID_TYPE_P (type)
-         /* We don't want to warn about delete of void*, only other
-            incomplete types.  Deleting other incomplete types
-            invokes undefined behavior, but it is not ill-formed, so
-            compile to something that would even do The Right Thing
-            (TM) should the type have a trivial dtor and no delete
-            operator.  */
-         || !complete_type_or_diagnostic (type, addr, 1)
-         || !IS_AGGR_TYPE (type))
+      /* We don't want to warn about delete of void*, only other
+         incomplete types.  Deleting other incomplete types
+         invokes undefined behavior, but it is not ill-formed, so
+         compile to something that would even do The Right Thing
+         (TM) should the type have a trivial dtor and no delete
+         operator.  */
+      if (!VOID_TYPE_P (type))
        {
-         /* Call the builtin operator delete.  */
-         return build_builtin_delete_call (addr);
+         complete_type (type);
+         if (!COMPLETE_TYPE_P (type))
+           {
+             warning ("possible problem detected in invocation of "
+                      "delete operator:");
+             cxx_incomplete_type_diagnostic (addr, type, 1);
+             inform ("neither the destructor nor the class-specific "\r
+                     "operator delete will be called, even if they are "\r
+                     "declared when the class is defined.");
+             complete_p = false;
+           }
        }
+      if (VOID_TYPE_P (type) || !complete_p || !IS_AGGR_TYPE (type))
+       /* Call the builtin operator delete.  */
+       return build_builtin_delete_call (addr);
       if (TREE_SIDE_EFFECTS (addr))
        addr = save_expr (addr);