call.c (build_op_delete_call): Avoid creating unnecessary types.
authorMark Mitchell <mark@codesourcery.com>
Thu, 15 May 2003 22:04:00 +0000 (22:04 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 15 May 2003 22:04:00 +0000 (22:04 +0000)
* call.c (build_op_delete_call): Avoid creating unnecessary types.
* class.c (instantiate_type): Remove tests for tf_no_attributes.
* cp-tree.h (tsubst_flags_t): Remove tf_no_attributes.
(COMPARE_NO_ATTRIBUTES): Remove.
* typeck.c (comptypes): Do not check COMPARE_NO_ATTRIBUTES.

From-SVN: r66843

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/typeck.c

index 4c01679e46a8a215e28412d3e2a83f26144c60ba..8e8d3e9a76aad82a01f12f34ec9df729c5347c7d 100644 (file)
@@ -1,5 +1,11 @@
 2003-05-15  Mark Mitchell  <mark@codesourcery.com>
 
+       * call.c (build_op_delete_call): Avoid creating unnecessary types.
+       * class.c (instantiate_type): Remove tests for tf_no_attributes.
+       * cp-tree.h (tsubst_flags_t): Remove tf_no_attributes.
+       (COMPARE_NO_ATTRIBUTES): Remove.
+       * typeck.c (comptypes): Do not check COMPARE_NO_ATTRIBUTES.
+
        PR c++/8385
        * semantics.c (finish_typeof): Refine type-dependency check.
 
index 84bdcd640d67a941600fb762f996d07d224a7753..1d40e4251072402f2952361ac5c2005f157221ee 100644 (file)
@@ -3953,7 +3953,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
                       int flags, tree placement)
 {
   tree fn = NULL_TREE;
-  tree fns, fnname, fntype, argtypes, args, type;
+  tree fns, fnname, argtypes, args, type;
   int pass;
 
   if (addr == error_mark_node)
@@ -4019,16 +4019,6 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
      the second pass we look for a two-argument delete.  */
   for (pass = 0; pass < (placement ? 1 : 2); ++pass) 
     {
-      if (pass == 0)
-       argtypes = tree_cons (NULL_TREE, ptr_type_node, argtypes);
-      else 
-       /* Normal delete; now try to find a match including the size
-          argument.  */
-       argtypes = tree_cons (NULL_TREE, ptr_type_node,
-                             tree_cons (NULL_TREE, sizetype, 
-                                        void_list_node));
-      fntype = build_function_type (void_type_node, argtypes);
-
       /* Go through the `operator delete' functions looking for one
         with a matching type.  */
       for (fn = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns; 
@@ -4037,13 +4027,30 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
        {
          tree t;
 
-         /* Exception specifications on the `delete' operator do not
-            matter.  */
-         t = build_exception_variant (TREE_TYPE (OVL_CURRENT (fn)),
-                                      NULL_TREE);
-         /* We also don't compare attributes.  We're really just
-            trying to check the types of the first two parameters.  */
-         if (comptypes (t, fntype, COMPARE_NO_ATTRIBUTES))
+         /* The first argument must be "void *".  */
+         t = TYPE_ARG_TYPES (TREE_TYPE (OVL_CURRENT (fn)));
+         if (!same_type_p (TREE_VALUE (t), ptr_type_node))
+           continue;
+         t = TREE_CHAIN (t);
+         /* On the first pass, check the rest of the arguments.  */
+         if (pass == 0)
+           {
+             while (argtypes && t)
+               {
+                 if (!same_type_p (TREE_VALUE (argtypes),
+                                   TREE_VALUE (t)))
+                   break;
+                 argtypes = TREE_CHAIN (argtypes);
+                 t = TREE_CHAIN (t);
+               }
+             if (!argtypes && !t)
+               break;
+           }
+         /* On the second pass, the second argument must be
+            "size_t".  */
+         else if (pass == 1
+                  && same_type_p (TREE_VALUE (t), sizetype)
+                  && TREE_CHAIN (t) == void_list_node)
            break;
        }
 
index c693fdf8e610ec8ed5f3cbf9e27cbfd144bf8706..773577d23e7b265efda4b94cda15915151a0afb9 100644 (file)
@@ -6017,8 +6017,6 @@ tree
 instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags)
 {
   int complain = (flags & tf_error);
-  int strict = (flags & tf_no_attributes)
-               ? COMPARE_NO_ATTRIBUTES : COMPARE_STRICT;
   int allow_ptrmem = flags & tf_ptrmem_ok;
   
   flags &= ~tf_ptrmem_ok;
@@ -6032,7 +6030,7 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags)
 
   if (TREE_TYPE (rhs) != NULL_TREE && ! (type_unknown_p (rhs)))
     {
-      if (comptypes (lhstype, TREE_TYPE (rhs), strict))
+      if (same_type_p (lhstype, TREE_TYPE (rhs)))
        return rhs;
       if (flag_ms_extensions 
          && TYPE_PTRMEMFUNC_P (lhstype)
index 33983982222977006d0bd4fbc69a97d4982993e4..78568edec2bebed6de49d7428db0c7904ebe3304 100644 (file)
@@ -3007,12 +3007,10 @@ typedef enum tsubst_flags_t {
   tf_none = 0,               /* nothing special */
   tf_error = 1 << 0,         /* give error messages  */
   tf_warning = 1 << 1,       /* give warnings too  */
-  tf_no_attributes = 1 << 2, /* ignore attributes on comparisons
-                               (instantiate_type use) */
-  tf_ignore_bad_quals = 1 << 3, /* ignore bad cvr qualifiers */
-  tf_keep_type_decl = 1 << 4,  /* retain typedef type decls
+  tf_ignore_bad_quals = 1 << 2, /* ignore bad cvr qualifiers */
+  tf_keep_type_decl = 1 << 3,  /* retain typedef type decls
                                   (make_typename_type use) */
-  tf_ptrmem_ok = 1 << 5      /* pointers to member ok (internal
+  tf_ptrmem_ok = 1 << 4      /* pointers to member ok (internal
                                instantiate_type use) */
 } tsubst_flags_t;
 
@@ -3372,8 +3370,6 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
 #define COMPARE_REDECLARATION 4 /* The comparsion is being done when
                                   another declaration of an existing
                                   entity is seen.  */
-#define COMPARE_NO_ATTRIBUTES 8 /* The comparison should ignore
-                                  extra-linguistic type attributes.  */
 
 /* Used with push_overloaded_decl.  */
 #define PUSH_GLOBAL          0  /* Push the DECL into namespace scope,
index 833d169a1018f0681986cb966453fdba36c5f0ed..7a3c18a59f520470d0a9b3f5a513b84a5a635f65 100644 (file)
@@ -971,11 +971,9 @@ comptypes (t1, t2, strict)
   if (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
     return 1;
 
-  if (strict & COMPARE_NO_ATTRIBUTES)
-    attrval = 1;
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
-  else if (! (attrval = (*targetm.comp_type_attributes) (t1, t2)))
-     return 0;
+  if (! (attrval = (*targetm.comp_type_attributes) (t1, t2)))
+    return 0;
 
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
   val = 0;