Commit 940ff223 by Jason Merrill Committed by Jason Merrill

cp-tree.h (COMPARE_NO_ATTRIBUTES): New macro.

	* 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
parent f2e2cbd4
1999-04-12 Jason Merrill <jason@yorick.cygnus.com> 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 * decl.c (xref_tag): Only complain once about using a typedef-name
with 'struct'. Downgrade to pedwarn. with 'struct'. Downgrade to pedwarn.
......
...@@ -2942,7 +2942,7 @@ build_op_delete_call (code, addr, size, flags, placement) ...@@ -2942,7 +2942,7 @@ build_op_delete_call (code, addr, size, flags, placement)
if (type != TYPE_MAIN_VARIANT (type)) if (type != TYPE_MAIN_VARIANT (type))
addr = cp_convert (build_pointer_type (TYPE_MAIN_VARIANT (type)), addr); 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) if (fn != error_mark_node)
{ {
...@@ -2962,11 +2962,11 @@ build_op_delete_call (code, addr, size, flags, placement) ...@@ -2962,11 +2962,11 @@ build_op_delete_call (code, addr, size, flags, placement)
tree_cons (NULL_TREE, sizetype, void_list_node)); tree_cons (NULL_TREE, sizetype, void_list_node));
fntype = build_function_type (void_type_node, argtypes); 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 (fn != error_mark_node)
{ {
if (TREE_CODE (fns) == TREE_LIST) if (BASELINK_P (fns))
/* Member functions. */ /* Member functions. */
enforce_access (TREE_PURPOSE (fns), fn); enforce_access (TREE_PURPOSE (fns), fn);
return build_function_call return build_function_call
......
...@@ -4919,14 +4919,19 @@ resolve_address_of_overloaded_function (target_type, ...@@ -4919,14 +4919,19 @@ resolve_address_of_overloaded_function (target_type,
try many possible instantiations, in hopes that at least one will try many possible instantiations, in hopes that at least one will
work. 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 For non-recursive calls, LHSTYPE should be a function, pointer to
function, or a pointer to member function. */ function, or a pointer to member function. */
tree tree
instantiate_type (lhstype, rhs, complain) instantiate_type (lhstype, rhs, flags)
tree lhstype, rhs; 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 (TREE_CODE (lhstype) == UNKNOWN_TYPE)
{ {
if (complain) if (complain)
...@@ -4936,7 +4941,7 @@ instantiate_type (lhstype, rhs, complain) ...@@ -4936,7 +4941,7 @@ instantiate_type (lhstype, rhs, complain)
if (TREE_TYPE (rhs) != NULL_TREE && ! (type_unknown_p (rhs))) 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; return rhs;
if (complain) if (complain)
cp_error ("argument of type `%T' does not match `%T'", cp_error ("argument of type `%T' does not match `%T'",
...@@ -4970,7 +4975,7 @@ instantiate_type (lhstype, rhs, complain) ...@@ -4970,7 +4975,7 @@ instantiate_type (lhstype, rhs, complain)
tree new_rhs; tree new_rhs;
new_rhs = instantiate_type (build_pointer_type (lhstype), new_rhs = instantiate_type (build_pointer_type (lhstype),
TREE_OPERAND (rhs, 0), complain); TREE_OPERAND (rhs, 0), flags);
if (new_rhs == error_mark_node) if (new_rhs == error_mark_node)
return error_mark_node; return error_mark_node;
...@@ -4982,14 +4987,14 @@ instantiate_type (lhstype, rhs, complain) ...@@ -4982,14 +4987,14 @@ instantiate_type (lhstype, rhs, complain)
case NOP_EXPR: case NOP_EXPR:
rhs = copy_node (TREE_OPERAND (rhs, 0)); rhs = copy_node (TREE_OPERAND (rhs, 0));
TREE_TYPE (rhs) = unknown_type_node; TREE_TYPE (rhs) = unknown_type_node;
return instantiate_type (lhstype, rhs, complain); return instantiate_type (lhstype, rhs, flags);
case COMPONENT_REF: case COMPONENT_REF:
{ {
tree field = TREE_OPERAND (rhs, 1); tree field = TREE_OPERAND (rhs, 1);
tree r; tree r;
r = instantiate_type (lhstype, field, complain); r = instantiate_type (lhstype, field, flags);
if (r != error_mark_node && TYPE_PTRMEMFUNC_P (lhstype)) if (r != error_mark_node && TYPE_PTRMEMFUNC_P (lhstype))
{ {
...@@ -5040,27 +5045,10 @@ instantiate_type (lhstype, rhs, complain) ...@@ -5040,27 +5045,10 @@ instantiate_type (lhstype, rhs, complain)
/*explicit_targs=*/NULL_TREE); /*explicit_targs=*/NULL_TREE);
case TREE_LIST: case TREE_LIST:
{ /* Now we should have a baselink. */
if (TREE_PURPOSE (rhs) == error_mark_node) my_friendly_assert (BASELINK_P (rhs), 990412);
{
/* 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. */ return instantiate_type (lhstype, TREE_VALUE (rhs), flags);
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);
}
case CALL_EXPR: case CALL_EXPR:
/* This is too hard for now. */ /* This is too hard for now. */
...@@ -5071,11 +5059,11 @@ instantiate_type (lhstype, rhs, complain) ...@@ -5071,11 +5059,11 @@ instantiate_type (lhstype, rhs, complain)
case MINUS_EXPR: case MINUS_EXPR:
case COMPOUND_EXPR: case COMPOUND_EXPR:
TREE_OPERAND (rhs, 0) 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) if (TREE_OPERAND (rhs, 0) == error_mark_node)
return error_mark_node; return error_mark_node;
TREE_OPERAND (rhs, 1) 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) if (TREE_OPERAND (rhs, 1) == error_mark_node)
return error_mark_node; return error_mark_node;
...@@ -5143,11 +5131,11 @@ instantiate_type (lhstype, rhs, complain) ...@@ -5143,11 +5131,11 @@ instantiate_type (lhstype, rhs, complain)
return error_mark_node; return error_mark_node;
} }
TREE_OPERAND (rhs, 1) 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) if (TREE_OPERAND (rhs, 1) == error_mark_node)
return error_mark_node; return error_mark_node;
TREE_OPERAND (rhs, 2) 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) if (TREE_OPERAND (rhs, 2) == error_mark_node)
return error_mark_node; return error_mark_node;
...@@ -5156,7 +5144,7 @@ instantiate_type (lhstype, rhs, complain) ...@@ -5156,7 +5144,7 @@ instantiate_type (lhstype, rhs, complain)
case MODIFY_EXPR: case MODIFY_EXPR:
TREE_OPERAND (rhs, 1) 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) if (TREE_OPERAND (rhs, 1) == error_mark_node)
return error_mark_node; return error_mark_node;
...@@ -5164,7 +5152,7 @@ instantiate_type (lhstype, rhs, complain) ...@@ -5164,7 +5152,7 @@ instantiate_type (lhstype, rhs, complain)
return rhs; return rhs;
case ADDR_EXPR: 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: case ENTRY_VALUE_EXPR:
my_friendly_abort (184); my_friendly_abort (184);
......
...@@ -2631,6 +2631,8 @@ extern tree current_class_name; /* IDENTIFIER_NODE: name of current class */ ...@@ -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 #define COMPARE_REDECLARATION 4 /* The comparsion is being done when
another declaration of an existing another declaration of an existing
entity is seen. */ entity is seen. */
#define COMPARE_NO_ATTRIBUTES 8 /* The comparison should ignore
extra-linguistic type attributes. */
/* Used with push_overloaded_decl. */ /* Used with push_overloaded_decl. */
#define PUSH_GLOBAL 0 /* Push the DECL into namespace scope, #define PUSH_GLOBAL 0 /* Push the DECL into namespace scope,
......
...@@ -869,8 +869,10 @@ comptypes (type1, type2, strict) ...@@ -869,8 +869,10 @@ comptypes (type1, type2, strict)
#define COMP_TYPE_ATTRIBUTES(t1,t2) 1 #define COMP_TYPE_ATTRIBUTES(t1,t2) 1
#endif #endif
if (strict & COMPARE_NO_ATTRIBUTES)
attrval = 1;
/* 1 if no need for warning yet, 2 if warning cause has been seen. */ /* 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; return 0;
/* 1 if no need for warning yet, 2 if warning cause has been seen. */ /* 1 if no need for warning yet, 2 if warning cause has been seen. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment