decl.c (cxx_maybe_build_cleanup): Always set LOOKUP_NONVIRTUAL.
authorJason Merrill <jason@redhat.com>
Thu, 31 Oct 2013 15:44:58 +0000 (11:44 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 31 Oct 2013 15:44:58 +0000 (11:44 -0400)
* decl.c (cxx_maybe_build_cleanup): Always set LOOKUP_NONVIRTUAL.
* decl2.c (build_cleanup): Just call cxx_maybe_build_cleanup.

From-SVN: r204265

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/decl2.c

index 34101530cf95df98a9fbe851db9be518e3e79d56..e0611100502473e49567cc9ded402d5269c10ce8 100644 (file)
@@ -1,5 +1,8 @@
 2013-10-31  Jason Merrill  <jason@redhat.com>
 
+       * decl.c (cxx_maybe_build_cleanup): Always set LOOKUP_NONVIRTUAL.
+       * decl2.c (build_cleanup): Just call cxx_maybe_build_cleanup.
+
        PR c++/58162
        * parser.c (cp_parser_late_parse_one_default_arg): Set
        TARGET_EXPR_DIRECT_INIT_P.
index 476d5594156e229bfc58875a39ae4f8e9c996a01..09c1daaa243e197573d88d224d92f71144e7a6c3 100644 (file)
@@ -14298,9 +14298,7 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain)
   type = TREE_TYPE (decl);
   if (type_build_dtor_call (type))
     {
-      int flags = LOOKUP_NORMAL|LOOKUP_DESTRUCTOR;
-      bool has_vbases = (TREE_CODE (type) == RECORD_TYPE
-                        && CLASSTYPE_VBASECLASSES (type));
+      int flags = LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR;
       tree addr;
       tree call;
 
@@ -14309,10 +14307,6 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain)
       else
        addr = build_address (decl);
 
-      /* Optimize for space over speed here.  */
-      if (!has_vbases || flag_expensive_optimizations)
-       flags |= LOOKUP_NONVIRTUAL;
-
       call = build_delete (TREE_TYPE (addr), addr,
                           sfk_complete_destructor, flags, 0, complain);
       if (call == error_mark_node)
index d776471607c67d1a06a5ec78c723353251266449..18e0e526d205918185579b445ed51b7b20cfd800 100644 (file)
@@ -2722,26 +2722,9 @@ import_export_decl (tree decl)
 tree
 build_cleanup (tree decl)
 {
-  tree temp;
-  tree type = TREE_TYPE (decl);
-
-  /* This function should only be called for declarations that really
-     require cleanups.  */
-  gcc_assert (!TYPE_HAS_TRIVIAL_DESTRUCTOR (type));
-
-  /* Treat all objects with destructors as used; the destructor may do
-     something substantive.  */
-  mark_used (decl);
-
-  if (TREE_CODE (type) == ARRAY_TYPE)
-    temp = decl;
-  else
-    temp = build_address (decl);
-  temp = build_delete (TREE_TYPE (temp), temp,
-                      sfk_complete_destructor,
-                      LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0,
-                      tf_warning_or_error);
-  return temp;
+  tree clean = cxx_maybe_build_cleanup (decl, tf_warning_or_error);
+  gcc_assert (clean != NULL_TREE);
+  return clean;
 }
 
 /* Returns the initialization guard variable for the variable DECL,