Commit 8f4b394d by Mark Mitchell Committed by Mark Mitchell

call.c (build_op_delete_call): Avoid creating unnecessary types.

	* 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
parent 7c942e17
2003-05-15 Mark Mitchell <mark@codesourcery.com> 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 PR c++/8385
* semantics.c (finish_typeof): Refine type-dependency check. * semantics.c (finish_typeof): Refine type-dependency check.
......
...@@ -3953,7 +3953,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, ...@@ -3953,7 +3953,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
int flags, tree placement) int flags, tree placement)
{ {
tree fn = NULL_TREE; tree fn = NULL_TREE;
tree fns, fnname, fntype, argtypes, args, type; tree fns, fnname, argtypes, args, type;
int pass; int pass;
if (addr == error_mark_node) if (addr == error_mark_node)
...@@ -4019,16 +4019,6 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, ...@@ -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. */ the second pass we look for a two-argument delete. */
for (pass = 0; pass < (placement ? 1 : 2); ++pass) 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 /* Go through the `operator delete' functions looking for one
with a matching type. */ with a matching type. */
for (fn = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns; 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, ...@@ -4037,13 +4027,30 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
{ {
tree t; tree t;
/* Exception specifications on the `delete' operator do not /* The first argument must be "void *". */
matter. */ t = TYPE_ARG_TYPES (TREE_TYPE (OVL_CURRENT (fn)));
t = build_exception_variant (TREE_TYPE (OVL_CURRENT (fn)), if (!same_type_p (TREE_VALUE (t), ptr_type_node))
NULL_TREE); continue;
/* We also don't compare attributes. We're really just t = TREE_CHAIN (t);
trying to check the types of the first two parameters. */ /* On the first pass, check the rest of the arguments. */
if (comptypes (t, fntype, COMPARE_NO_ATTRIBUTES)) 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; break;
} }
......
...@@ -6017,8 +6017,6 @@ tree ...@@ -6017,8 +6017,6 @@ tree
instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags) instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags)
{ {
int complain = (flags & tf_error); int complain = (flags & tf_error);
int strict = (flags & tf_no_attributes)
? COMPARE_NO_ATTRIBUTES : COMPARE_STRICT;
int allow_ptrmem = flags & tf_ptrmem_ok; int allow_ptrmem = flags & tf_ptrmem_ok;
flags &= ~tf_ptrmem_ok; flags &= ~tf_ptrmem_ok;
...@@ -6032,7 +6030,7 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags) ...@@ -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 (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; return rhs;
if (flag_ms_extensions if (flag_ms_extensions
&& TYPE_PTRMEMFUNC_P (lhstype) && TYPE_PTRMEMFUNC_P (lhstype)
......
...@@ -3007,12 +3007,10 @@ typedef enum tsubst_flags_t { ...@@ -3007,12 +3007,10 @@ typedef enum tsubst_flags_t {
tf_none = 0, /* nothing special */ tf_none = 0, /* nothing special */
tf_error = 1 << 0, /* give error messages */ tf_error = 1 << 0, /* give error messages */
tf_warning = 1 << 1, /* give warnings too */ tf_warning = 1 << 1, /* give warnings too */
tf_no_attributes = 1 << 2, /* ignore attributes on comparisons tf_ignore_bad_quals = 1 << 2, /* ignore bad cvr qualifiers */
(instantiate_type use) */ tf_keep_type_decl = 1 << 3, /* retain typedef type decls
tf_ignore_bad_quals = 1 << 3, /* ignore bad cvr qualifiers */
tf_keep_type_decl = 1 << 4, /* retain typedef type decls
(make_typename_type use) */ (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) */ instantiate_type use) */
} tsubst_flags_t; } tsubst_flags_t;
...@@ -3372,8 +3370,6 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG }; ...@@ -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 #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,
......
...@@ -971,11 +971,9 @@ comptypes (t1, t2, strict) ...@@ -971,11 +971,9 @@ comptypes (t1, t2, strict)
if (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2)) if (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
return 1; return 1;
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. */
else if (! (attrval = (*targetm.comp_type_attributes) (t1, t2))) if (! (attrval = (*targetm.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. */
val = 0; val = 0;
......
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