Commit ceab47eb by Mark Mitchell Committed by Mark Mitchell

call.c (compare_qual): Remove.

	* call.c (compare_qual): Remove.
	(is_subseq): Tweak.
	(is_properly_derived_from): New function.
	(maybe_handle_ref_bind): Likewise.
	(maybe_handle_implicit_object): Likewise.
	(compare_ics): Modify substantially to bring into conformance with
	the standard.
	* cp-tree.h (TYPE_PTRMEMFUNC_OBJECT_TYPE): New macro.
	(comp_cv_qualification): Declare.
	(comp_cv_qual_signature): Likewise.
	* typeck.c (comp_cv_qualification): Likewise.
	(comp_cv_qual_signature): Likewise.

From-SVN: r19880
parent 06033860
Tue May 19 14:50:27 1998 Mark Mitchell <mmitchell@usa.net>
* call.c (compare_qual): Remove.
(is_subseq): Tweak.
(is_properly_derived_from): New function.
(maybe_handle_ref_bind): Likewise.
(maybe_handle_implicit_object): Likewise.
(compare_ics): Modify substantially to bring into conformance with
the standard.
* cp-tree.h (TYPE_PTRMEMFUNC_OBJECT_TYPE): New macro.
(comp_cv_qualification): Declare.
(comp_cv_qual_signature): Likewise.
* typeck.c (comp_cv_qualification): Likewise.
(comp_cv_qual_signature): Likewise.
Tue May 19 10:05:02 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> Tue May 19 10:05:02 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Makefile.in (parse.o): Depend on toplev.h. * Makefile.in (parse.o): Depend on toplev.h.
......
...@@ -1362,6 +1362,11 @@ extern int flag_new_for_scope; ...@@ -1362,6 +1362,11 @@ extern int flag_new_for_scope;
pointer to member function. TYPE_PTRMEMFUNC_P _must_ be true, pointer to member function. TYPE_PTRMEMFUNC_P _must_ be true,
before using this macro. */ before using this macro. */
#define TYPE_PTRMEMFUNC_FN_TYPE(NODE) (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (NODE))))))) #define TYPE_PTRMEMFUNC_FN_TYPE(NODE) (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (NODE)))))))
/* Returns `A' for a type like `int (A::*)(double)' */
#define TYPE_PTRMEMFUNC_OBJECT_TYPE(NODE) \
TYPE_METHOD_BASETYPE (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (NODE)))
/* These are use to manipulate the canonical RECORD_TYPE from the /* These are use to manipulate the canonical RECORD_TYPE from the
hashed POINTER_TYPE, and can only be used on the POINTER_TYPE. */ hashed POINTER_TYPE, and can only be used on the POINTER_TYPE. */
#define TYPE_GET_PTRMEMFUNC_TYPE(NODE) ((tree)TYPE_LANG_SPECIFIC(NODE)) #define TYPE_GET_PTRMEMFUNC_TYPE(NODE) ((tree)TYPE_LANG_SPECIFIC(NODE))
...@@ -2770,6 +2775,8 @@ extern int comptypes PROTO((tree, tree, int)); ...@@ -2770,6 +2775,8 @@ extern int comptypes PROTO((tree, tree, int));
extern int comp_target_types PROTO((tree, tree, int)); extern int comp_target_types PROTO((tree, tree, int));
extern int compparms PROTO((tree, tree, int)); extern int compparms PROTO((tree, tree, int));
extern int comp_target_types PROTO((tree, tree, int)); extern int comp_target_types PROTO((tree, tree, int));
extern int comp_cv_qualification PROTO((tree, tree));
extern int comp_cv_qual_signature PROTO((tree, tree));
extern int self_promoting_args_p PROTO((tree)); extern int self_promoting_args_p PROTO((tree));
extern tree unsigned_type PROTO((tree)); extern tree unsigned_type PROTO((tree));
extern tree signed_type PROTO((tree)); extern tree signed_type PROTO((tree));
......
...@@ -1048,6 +1048,46 @@ comp_target_types (ttl, ttr, nptrs) ...@@ -1048,6 +1048,46 @@ comp_target_types (ttl, ttr, nptrs)
return 0; return 0;
} }
/* Returns 1 if TYPE1 is more cv-qualified than TYPE2, -1 if TYPE2 is
more cv-qualified that TYPE1, and 0 otherwise. */
int
comp_cv_qualification (type1, type2)
tree type1;
tree type2;
{
if (TYPE_READONLY (type1) == TYPE_READONLY (type2)
&& TYPE_VOLATILE (type1) == TYPE_VOLATILE (type2))
return 0;
if (TYPE_READONLY (type1) >= TYPE_READONLY (type2)
&& TYPE_VOLATILE (type1) >= TYPE_VOLATILE (type2))
return 1;
if (TYPE_READONLY (type2) >= TYPE_READONLY (type1)
&& TYPE_VOLATILE (type2) >= TYPE_VOLATILE (type1))
return -1;
return 0;
}
/* Returns 1 if the cv-qualification signature of TYPE1 is a proper
subset of the cv-qualification signature of TYPE2, and the types
are similar. Returns -1 if the other way 'round, and 0 otherwise. */
int
comp_cv_qual_signature (type1, type2)
tree type1;
tree type2;
{
if (comp_ptr_ttypes_real (type2, type1, -1))
return 1;
else if (comp_ptr_ttypes_real (type1, type2, -1))
return -1;
else
return 0;
}
/* If two types share a common base type, return that basetype. /* If two types share a common base type, return that basetype.
If there is not a unique most-derived base type, this function If there is not a unique most-derived base type, this function
returns ERROR_MARK_NODE. */ returns ERROR_MARK_NODE. */
...@@ -7409,14 +7449,21 @@ c_expand_start_case (exp) ...@@ -7409,14 +7449,21 @@ c_expand_start_case (exp)
return exp; return exp;
} }
/* CONSTP remembers whether or not all the intervening pointers in the `to' /* Returns non-zero if the pointer-type FROM can be converted to the
type have been const. */ pointer-type TO via a qualification conversion. If CONSTP is -1,
then we return non-zero if the pointers are similar, and the
cv-qualification signature of FROM is a proper subset of that of TO.
If CONSTP is positive, then all outer pointers have been
const-qualified. */
static int static int
comp_ptr_ttypes_real (to, from, constp) comp_ptr_ttypes_real (to, from, constp)
tree to, from; tree to, from;
int constp; int constp;
{ {
int to_more_cv_qualified = 0;
for (; ; to = TREE_TYPE (to), from = TREE_TYPE (from)) for (; ; to = TREE_TYPE (to), from = TREE_TYPE (from))
{ {
if (TREE_CODE (to) != TREE_CODE (from)) if (TREE_CODE (to) != TREE_CODE (from))
...@@ -7431,19 +7478,32 @@ comp_ptr_ttypes_real (to, from, constp) ...@@ -7431,19 +7478,32 @@ comp_ptr_ttypes_real (to, from, constp)
so the usual checks are not appropriate. */ so the usual checks are not appropriate. */
if (TREE_CODE (to) != FUNCTION_TYPE && TREE_CODE (to) != METHOD_TYPE) if (TREE_CODE (to) != FUNCTION_TYPE && TREE_CODE (to) != METHOD_TYPE)
{ {
if (TYPE_READONLY (from) > TYPE_READONLY (to) switch (comp_cv_qualification (from, to))
|| TYPE_VOLATILE (from) > TYPE_VOLATILE (to)) {
return 0; case 1:
/* FROM is more cv-qualified than TO. */
return 0;
if (! constp case -1:
&& (TYPE_READONLY (to) > TYPE_READONLY (from) /* TO is more cv-qualified than FROM. */
|| TYPE_VOLATILE (to) > TYPE_READONLY (from))) if (constp == 0)
return 0; return 0;
constp &= TYPE_READONLY (to); else
++to_more_cv_qualified;
break;
default:
break;
}
if (constp > 0)
constp &= TYPE_READONLY (to);
} }
if (TREE_CODE (to) != POINTER_TYPE) if (TREE_CODE (to) != POINTER_TYPE)
return comptypes (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from), 1); return
comptypes (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from), 1)
&& (constp >= 0 || to_more_cv_qualified);
} }
} }
......
// Build don't run:
void f(const int *);
void f(int *) {}
void f2(const volatile int *);
void f2(volatile int *) {}
int i;
int main()
{
f(&i);
f2(&i);
}
// Build don't run:
void f(int* const volatile * const * const*);
void f(int* const * const * const*) {}
int main()
{
int*** ip;
f(&ip);
}
// Build don't run:
struct S {};
struct T : public S {};
struct U : public T {};
void f(int T::*) {}
void f(int U::*);
void g(void (T::*)(int)) {}
void g(void (U::*)(int));
int main()
{
int S::*ip;
void (S::*fp)(int);
f(ip);
g(fp);
}
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