cp-tree.h (COMPARE_NO_ATTRIBUTES): New macro.
authorJason Merrill <jason@yorick.cygnus.com>
Tue, 13 Apr 1999 00:20:42 +0000 (00:20 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 13 Apr 1999 00:20:42 +0000 (20:20 -0400)
* cp-tree.h (COMPARE_NO_ATTRIBUTES): New macro.
* typeck.c (comptypes): If we get it, ignore attributes.
* class.c (instantiate_type): Use BASELINK_P.  Change complain
parameter to flags; 2 means ignore attributes.
* call.c (build_op_delete_call): Pass it.

From-SVN: r26393

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

index 5531d63f4ac8890db5337b7b23156e3ae3bc19ee..304a1229860e36ba4548933bf98c4e29bc8bc571 100644 (file)
@@ -1,5 +1,11 @@
 1999-04-12  Jason Merrill  <jason@yorick.cygnus.com>
 
+       * cp-tree.h (COMPARE_NO_ATTRIBUTES): New macro.
+       * typeck.c (comptypes): If we get it, ignore attributes.
+       * class.c (instantiate_type): Use BASELINK_P.  Change complain
+       parameter to flags; 2 means ignore attributes.  
+       * call.c (build_op_delete_call): Pass it.
+
        * decl.c (xref_tag): Only complain once about using a typedef-name
        with 'struct'.  Downgrade to pedwarn.
 
index f3ef258d8694b4cb50656418368f26bc0b1289c8..fb3df65ae9059c62af889bcc3c96e71065abf1c9 100644 (file)
@@ -2942,7 +2942,7 @@ build_op_delete_call (code, addr, size, flags, placement)
   if (type != TYPE_MAIN_VARIANT (type))
     addr = cp_convert (build_pointer_type (TYPE_MAIN_VARIANT (type)), addr);
 
-  fn = instantiate_type (fntype, fns, 0);
+  fn = instantiate_type (fntype, fns, 2);
 
   if (fn != error_mark_node)
     {
@@ -2962,11 +2962,11 @@ build_op_delete_call (code, addr, size, flags, placement)
                        tree_cons (NULL_TREE, sizetype, void_list_node));
   fntype = build_function_type (void_type_node, argtypes);
 
-  fn = instantiate_type (fntype, fns, 0);
+  fn = instantiate_type (fntype, fns, 2);
 
   if (fn != error_mark_node)
     {
-      if (TREE_CODE (fns) == TREE_LIST)
+      if (BASELINK_P (fns))
        /* Member functions.  */
        enforce_access (TREE_PURPOSE (fns), fn);
       return build_function_call
index 6b7b98a3aa998599166a03a4f7e8ab35fb0b4792..a577441aba3f9882613bbcade2e1ad8a085d51a3 100644 (file)
@@ -4919,14 +4919,19 @@ resolve_address_of_overloaded_function (target_type,
    try many possible instantiations, in hopes that at least one will
    work.
 
+   FLAGS is a bitmask, as we see at the top of the function.
+
    For non-recursive calls, LHSTYPE should be a function, pointer to
    function, or a pointer to member function.  */
 
 tree
-instantiate_type (lhstype, rhs, complain)
+instantiate_type (lhstype, rhs, flags)
      tree lhstype, rhs;
-     int complain;
+     int flags;
 {
+  int complain = (flags & 1);
+  int strict = (flags & 2) ? COMPARE_NO_ATTRIBUTES : COMPARE_STRICT;
+
   if (TREE_CODE (lhstype) == UNKNOWN_TYPE)
     {
       if (complain)
@@ -4936,7 +4941,7 @@ instantiate_type (lhstype, rhs, complain)
 
   if (TREE_TYPE (rhs) != NULL_TREE && ! (type_unknown_p (rhs)))
     {
-      if (same_type_p (lhstype, TREE_TYPE (rhs)))
+      if (comptypes (lhstype, TREE_TYPE (rhs), strict))
        return rhs;
       if (complain)
        cp_error ("argument of type `%T' does not match `%T'",
@@ -4970,7 +4975,7 @@ instantiate_type (lhstype, rhs, complain)
        tree new_rhs;
 
        new_rhs = instantiate_type (build_pointer_type (lhstype),
-                                   TREE_OPERAND (rhs, 0), complain);
+                                   TREE_OPERAND (rhs, 0), flags);
        if (new_rhs == error_mark_node)
          return error_mark_node;
 
@@ -4982,14 +4987,14 @@ instantiate_type (lhstype, rhs, complain)
     case NOP_EXPR:
       rhs = copy_node (TREE_OPERAND (rhs, 0));
       TREE_TYPE (rhs) = unknown_type_node;
-      return instantiate_type (lhstype, rhs, complain);
+      return instantiate_type (lhstype, rhs, flags);
 
     case COMPONENT_REF:
       {
        tree field = TREE_OPERAND (rhs, 1);
        tree r;
 
-       r = instantiate_type (lhstype, field, complain);
+       r = instantiate_type (lhstype, field, flags);
 
        if (r != error_mark_node && TYPE_PTRMEMFUNC_P (lhstype))
          {
@@ -5040,27 +5045,10 @@ instantiate_type (lhstype, rhs, complain)
                                                /*explicit_targs=*/NULL_TREE);
 
     case TREE_LIST:
-      {
-       if (TREE_PURPOSE (rhs) == error_mark_node)
-         {
-           /* Make sure we don't drop the non-local flag, as the old code
-              would rely on it. */
-           int nl = TREE_NONLOCAL_FLAG (rhs);
-           /* We don't need the type of this node. */
-           rhs = TREE_VALUE (rhs);
-           my_friendly_assert (TREE_NONLOCAL_FLAG (rhs) == nl, 980331);
-         }
+      /* Now we should have a baselink. */
+      my_friendly_assert (BASELINK_P (rhs), 990412);
 
-       /* Now we should have a baselink. */
-       my_friendly_assert (TREE_CODE (TREE_PURPOSE (rhs)) == TREE_VEC,
-                           980331);
-       my_friendly_assert (TREE_CHAIN (rhs) == NULL_TREE, 181);
-       my_friendly_assert (TREE_CODE (TREE_VALUE (rhs)) == FUNCTION_DECL
-                           || TREE_CODE (TREE_VALUE (rhs)) == OVERLOAD,
-                           182);
-
-       return instantiate_type (lhstype, TREE_VALUE (rhs), complain);
-      }
+      return instantiate_type (lhstype, TREE_VALUE (rhs), flags);
 
     case CALL_EXPR:
       /* This is too hard for now.  */
@@ -5071,11 +5059,11 @@ instantiate_type (lhstype, rhs, complain)
     case MINUS_EXPR:
     case COMPOUND_EXPR:
       TREE_OPERAND (rhs, 0)
-       = instantiate_type (lhstype, TREE_OPERAND (rhs, 0), complain);
+       = instantiate_type (lhstype, TREE_OPERAND (rhs, 0), flags);
       if (TREE_OPERAND (rhs, 0) == error_mark_node)
        return error_mark_node;
       TREE_OPERAND (rhs, 1)
-       = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), complain);
+       = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), flags);
       if (TREE_OPERAND (rhs, 1) == error_mark_node)
        return error_mark_node;
 
@@ -5143,11 +5131,11 @@ instantiate_type (lhstype, rhs, complain)
          return error_mark_node;
        }
       TREE_OPERAND (rhs, 1)
-       = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), complain);
+       = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), flags);
       if (TREE_OPERAND (rhs, 1) == error_mark_node)
        return error_mark_node;
       TREE_OPERAND (rhs, 2)
-       = instantiate_type (lhstype, TREE_OPERAND (rhs, 2), complain);
+       = instantiate_type (lhstype, TREE_OPERAND (rhs, 2), flags);
       if (TREE_OPERAND (rhs, 2) == error_mark_node)
        return error_mark_node;
 
@@ -5156,7 +5144,7 @@ instantiate_type (lhstype, rhs, complain)
 
     case MODIFY_EXPR:
       TREE_OPERAND (rhs, 1)
-       = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), complain);
+       = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), flags);
       if (TREE_OPERAND (rhs, 1) == error_mark_node)
        return error_mark_node;
 
@@ -5164,7 +5152,7 @@ instantiate_type (lhstype, rhs, complain)
       return rhs;
       
     case ADDR_EXPR:
-      return instantiate_type (lhstype, TREE_OPERAND (rhs, 0), complain);
+      return instantiate_type (lhstype, TREE_OPERAND (rhs, 0), flags);
 
     case ENTRY_VALUE_EXPR:
       my_friendly_abort (184);
index 0ed7d750232ecf1aebf99029d0b5f2e82c94e546..a88156d44618d7a2a8f739f478681a368b56317e 100644 (file)
@@ -2631,6 +2631,8 @@ extern tree current_class_name;   /* IDENTIFIER_NODE: name of current class */
 #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 6016d91df0816f45b6f0e65a5c4d60c57172ab48..c210410102a0c6a136b5d6f750c63b44cb86099a 100644 (file)
@@ -869,8 +869,10 @@ comptypes (type1, type2, strict)
 #define COMP_TYPE_ATTRIBUTES(t1,t2)    1
 #endif
 
+  if (strict & COMPARE_NO_ATTRIBUTES)
+    attrval = 1;
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
-  if (! (attrval = COMP_TYPE_ATTRIBUTES (t1, t2)))
+  else if (! (attrval = COMP_TYPE_ATTRIBUTES (t1, t2)))
      return 0;
 
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */