Deleted Added
full compact
2c2
< Copyright (C) 1987, 88, 89, 92-97, 1998 Free Software Foundation, Inc.
---
> Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
42,44c42
< extern void compiler_error ();
<
< static tree convert_for_assignment PROTO((tree, tree, char*, tree,
---
> static tree convert_for_assignment PROTO((tree, tree, const char *, tree,
54d51
< static tree build_ptrmemfunc1 PROTO((tree, tree, tree, tree, tree));
60a58
> static tree build_component_addr PROTO((tree, tree));
62a61
> static int comp_cv_target_types PROTO((tree, tree, int));
83c82,84
< does not have an incomplete type. (That includes void types.) */
---
> does not have an incomplete type. (That includes void types.)
> Returns the error_mark_node if the VALUE does not have
> complete type when this function returns. */
91c92
< if (processing_template_decl)
---
> if (processing_template_decl || value == error_mark_node)
101c102
< && type != void_type_node
---
> && TYPE_SIZE (type) != size_zero_node
123c124
< if (TYPE_SIZE (complete_type (type)))
---
> if (complete_type_or_else (type, value))
125a127,140
> return error_mark_node;
> }
>
> /* Makes sure EXPR is a complete type when used in a void context, like a
> whole expression, or lhs of a comma operator. Issue a diagnostic and
> return error_mark_node on failure. This is a little tricky, because some
> valid void types look stunningly similar to invalid void types. We err on
> the side of caution */
>
> tree
> require_complete_type_in_void (expr)
> tree expr;
> {
> switch (TREE_CODE (expr))
127,128c142,217
< incomplete_type_error (value, type);
< return error_mark_node;
---
> case COND_EXPR:
> {
> tree op;
>
> op = TREE_OPERAND (expr,2);
> op = require_complete_type_in_void (op);
> TREE_OPERAND (expr,2) = op;
> if (op == error_mark_node)
> {
> expr = op;
> break;
> }
>
> /* fallthrough */
> }
>
> case COMPOUND_EXPR:
> {
> tree op;
>
> op = TREE_OPERAND (expr,1);
> op = require_complete_type_in_void (op);
> TREE_OPERAND (expr,1) = op;
> if (op == error_mark_node)
> {
> expr = op;
> break;
> }
>
> break;
> }
>
> case NON_LVALUE_EXPR:
> case NOP_EXPR:
> {
> tree op;
>
> op = TREE_OPERAND (expr,0);
> op = require_complete_type_in_void (op);
> TREE_OPERAND (expr,0) = op;
> if (op == error_mark_node)
> {
> expr = op;
> break;
> }
> break;
> }
>
> case CALL_EXPR: /* function call return can be ignored */
> case RTL_EXPR: /* RTL nodes have no value */
> case DELETE_EXPR: /* delete expressions have no type */
> case VEC_DELETE_EXPR:
> case INTEGER_CST: /* used for null pointer */
> case EXIT_EXPR: /* have no return */
> case LOOP_EXPR: /* have no return */
> case BIND_EXPR: /* have no return */
> case THROW_EXPR: /* have no return */
> case MODIFY_EXPR: /* sometimes this has a void type, but that's ok */
> case CONVERT_EXPR: /* sometimes has a void type */
> break;
>
> case INDIRECT_REF:
> {
> tree op = TREE_OPERAND (expr,0);
>
> /* Calling a function returning a reference has an implicit
> dereference applied. We don't want to make that an error. */
> if (TREE_CODE (op) == CALL_EXPR
> && TREE_CODE (TREE_TYPE (op)) == REFERENCE_TYPE)
> break;
> /* else fallthrough */
> }
>
> default:
> expr = require_complete_type (expr);
> break;
129a219,220
>
> return expr;
158c249
< else if (IS_AGGR_TYPE (type) && CLASSTYPE_TEMPLATE_INSTANTIATION (type))
---
> else if (CLASS_TYPE_P (type) && CLASSTYPE_TEMPLATE_INSTANTIATION (type))
165,166c256,257
< completed. Returns NULL_TREE if the type cannot be made
< complete. */
---
> completed. VALUE is used for informative diagnostics.
> Returns NULL_TREE if the type cannot be made complete. */
169c260
< complete_type_or_else (type)
---
> complete_type_or_else (type, value)
170a262
> tree value;
173c265,268
< if (type != error_mark_node && !TYPE_SIZE (type))
---
> if (type == error_mark_node)
> /* We already issued an error. */
> return NULL_TREE;
> else if (!TYPE_SIZE (type) || TYPE_SIZE (type) == size_zero_node)
175c270
< incomplete_type_error (NULL_TREE, type);
---
> incomplete_type_error (value, type);
207,232d301
< /* Do `exp = require_instantiated_type (type, exp);' to make sure EXP
< does not have an uninstantiated type.
< TYPE is type to instantiate with, if uninstantiated. */
<
< tree
< require_instantiated_type (type, exp, errval)
< tree type, exp, errval;
< {
< if (TREE_TYPE (exp) == NULL_TREE)
< {
< error ("argument list may not have an initializer list");
< return errval;
< }
<
< if (TREE_CODE (exp) == OVERLOAD
< || TREE_TYPE (exp) == unknown_type_node
< || (TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE
< && TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node))
< {
< exp = instantiate_type (type, exp, 1);
< if (TREE_TYPE (exp) == error_mark_node)
< return errval;
< }
< return exp;
< }
<
240,241d308
< int constflag = TYPE_READONLY (type) || TYPE_READONLY (like);
< int volflag = TYPE_VOLATILE (type) || TYPE_VOLATILE (like);
243c310,311
< return cp_build_type_variant (type, constflag, volflag);
---
> return cp_build_qualified_type (type, (CP_TYPE_QUALS (type)
> | CP_TYPE_QUALS (like)));
497,502c565,568
< tree tt1 = TYPE_MAIN_VARIANT (TREE_TYPE (t1));
< tree tt2 = TYPE_MAIN_VARIANT (TREE_TYPE (t2));
< int constp
< = TYPE_READONLY (TREE_TYPE (t1)) || TYPE_READONLY (TREE_TYPE (t2));
< int volatilep
< = TYPE_VOLATILE (TREE_TYPE (t1)) || TYPE_VOLATILE (TREE_TYPE (t2));
---
> tree tt1 = TREE_TYPE (t1);
> tree tt2 = TREE_TYPE (t2);
> tree b1, b2;
> int type_quals;
504a571,584
> if (TREE_CODE (tt1) == OFFSET_TYPE)
> {
> b1 = TYPE_OFFSET_BASETYPE (tt1);
> b2 = TYPE_OFFSET_BASETYPE (tt2);
> tt1 = TREE_TYPE (tt1);
> tt2 = TREE_TYPE (tt2);
> }
> else
> b1 = b2 = NULL_TREE;
>
> type_quals = (CP_TYPE_QUALS (tt1) | CP_TYPE_QUALS (tt2));
> tt1 = TYPE_MAIN_VARIANT (tt1);
> tt2 = TYPE_MAIN_VARIANT (tt2);
>
506a587,591
> else if (b1)
> {
> compiler_error ("common_type called with uncommon member types");
> target = tt1;
> }
516c601,611
< target = cp_build_type_variant (target, constp, volatilep);
---
> target = cp_build_qualified_type (target, type_quals);
>
> if (b1)
> {
> if (same_type_p (b1, b2)
> || (DERIVED_FROM_P (b1, b2) && binfo_or_else (b1, b2)))
> target = build_offset_type (b2, target);
> else if (binfo_or_else (b2, b1))
> target = build_offset_type (b1, target);
> }
>
590c685,688
< compiler_error ("common_type called with uncommon aggregate types");
---
> {
> compiler_error ("common_type called with uncommon aggregate types");
> return error_mark_node;
> }
603c701
< if (comptypes (b1, b2, 1)
---
> if (same_type_p (b1, b2)
633,636c731,733
< if (TREE_TYPE (t1) == TREE_TYPE (t2))
< {
< tree b1 = TYPE_OFFSET_BASETYPE (t1);
< tree b2 = TYPE_OFFSET_BASETYPE (t2);
---
> /* Pointers to members should now be handled by the POINTER_TYPE
> case above. */
> my_friendly_abort (990325);
638,645d734
< if (comptypes (b1, b2, 1)
< || (DERIVED_FROM_P (b1, b2) && binfo_or_else (b1, b2)))
< return build_type_attribute_variant (t2, attributes);
< else if (binfo_or_else (b2, b1))
< return build_type_attribute_variant (t1, attributes);
< }
< compiler_error ("common_type called with uncommon member types");
<
659a749,751
> /* Compare the array types T1 and T2, using CMP as the type comparison
> function for the element types. STRICT is as for comptypes. */
>
666,667c758,759
< tree d1 = TYPE_DOMAIN (t1);
< tree d2 = TYPE_DOMAIN (t2);
---
> tree d1;
> tree d2;
669c761,764
< /* Target types must match incl. qualifiers. */
---
> if (t1 == t2)
> return 1;
>
> /* The type of the array elements must be the same. */
671c766,767
< || (*cmp) (TREE_TYPE (t1), TREE_TYPE (t2), strict)))
---
> || (*cmp) (TREE_TYPE (t1), TREE_TYPE (t2),
> strict & ~COMPARE_REDECLARATION)))
674,679c770,773
< /* Sizes must match unless one is missing or variable. */
< if (d1 == 0 || d2 == 0 || d1 == d2
< || TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
< || TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
< || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST
< || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST)
---
> d1 = TYPE_DOMAIN (t1);
> d2 = TYPE_DOMAIN (t2);
>
> if (d1 == d2)
682,690c776,778
< return ((TREE_INT_CST_LOW (TYPE_MIN_VALUE (d1))
< == TREE_INT_CST_LOW (TYPE_MIN_VALUE (d2)))
< && (TREE_INT_CST_HIGH (TYPE_MIN_VALUE (d1))
< == TREE_INT_CST_HIGH (TYPE_MIN_VALUE (d2)))
< && (TREE_INT_CST_LOW (TYPE_MAX_VALUE (d1))
< == TREE_INT_CST_LOW (TYPE_MAX_VALUE (d2)))
< && (TREE_INT_CST_HIGH (TYPE_MAX_VALUE (d1))
< == TREE_INT_CST_HIGH (TYPE_MAX_VALUE (d2))));
< }
---
> /* If one of the arrays is dimensionless, and the other has a
> dimension, they are of different types. However, it is legal to
> write:
692,694c780,781
< /* Return 1 if TYPE1 and TYPE2 are compatible types for assignment
< or various other operations. This is what ANSI C++ speaks of as
< "being the same".
---
> extern int a[];
> int a[3];
696,697c783
< For C++: argument STRICT says we should be strict about this
< comparison:
---
> by [basic.link]:
699,706c785,789
< 2 : strict, except that if one type is a reference and
< the other is not, compare the target type of the
< reference to the type that's not a reference (ARM, p308).
< This is used for checking for invalid overloading.
< 1 : strict (compared according to ANSI C)
< This is used for checking whether two function decls match.
< 0 : <= (compared according to C++)
< -1: <= or >= (relaxed)
---
> declarations for an array object can specify
> array types that differ by the presence or absence of a major
> array bound (_dcl.array_). */
> if (!d1 || !d2)
> return strict & COMPARE_REDECLARATION;
708,714c791,796
< Otherwise, pointers involving base classes and derived classes can
< be mixed as valid: i.e. a pointer to a derived class may be converted
< to a pointer to one of its base classes, as per C++. A pointer to
< a derived class may be passed as a parameter to a function expecting a
< pointer to a base classes. These allowances do not commute. In this
< case, TYPE1 is assumed to be the base class, and TYPE2 is assumed to
< be the derived class. */
---
> /* Check that the dimensions are the same. */
> return (cp_tree_equal (TYPE_MIN_VALUE (d1),
> TYPE_MIN_VALUE (d2))
> && cp_tree_equal (TYPE_MAX_VALUE (d1),
> TYPE_MAX_VALUE (d2)));
> }
715a798,801
> /* Return 1 if TYPE1 and TYPE2 are compatible types for assignment
> or various other operations. STRICT is a bitwise-or of the
> COMPARE_* flags. */
>
723a810
> int orig_strict = strict;
725c812,813
< /* Suppress errors caused by previously reported errors */
---
> /* The special exemption for redeclaring array types without an
> array bound only applies at the top level:
726a815,821
> extern int (*i)[];
> int (*i)[8];
>
> is not legal, for example. */
> strict &= ~COMPARE_REDECLARATION;
>
> /* Suppress errors caused by previously reported errors */
736c831
< if (strict < 0)
---
> if (strict & COMPARE_RELAXED)
755d849
<
757,765c851
< {
< if (strict == 2
< && ((TREE_CODE (t1) == REFERENCE_TYPE)
< ^ (TREE_CODE (t2) == REFERENCE_TYPE)))
< {
< if (TREE_CODE (t1) == REFERENCE_TYPE)
< return comptypes (TREE_TYPE (t1), t2, 1);
< return comptypes (t1, TREE_TYPE (t2), 1);
< }
---
> return 0;
767,771d852
< return 0;
< }
< if (strict > 1)
< strict = 1;
<
773,774c854
<
< if (TYPE_READONLY (t1) != TYPE_READONLY (t2))
---
> if (CP_TYPE_QUALS (t1) != CP_TYPE_QUALS (t2))
776c856,857
< if (TYPE_VOLATILE (t1) != TYPE_VOLATILE (t2))
---
> if (strict == COMPARE_STRICT
> && TYPE_FOR_JAVA (t1) != TYPE_FOR_JAVA (t2))
778,779d858
< if (strict > 0 && TYPE_FOR_JAVA (t1) != TYPE_FOR_JAVA (t2))
< return 0;
793a873,874
> if (strict & COMPARE_NO_ATTRIBUTES)
> attrval = 1;
795c876
< if (! (attrval = COMP_TYPE_ATTRIBUTES (t1, t2)))
---
> else if (! (attrval = COMP_TYPE_ATTRIBUTES (t1, t2)))
810c891,892
< if (! CLASSTYPE_TEMPLATE_INFO (t1) && ! CLASSTYPE_TEMPLATE_INFO (t2))
---
> if (!TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t1)
> && ! TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t2))
813c895
< strict = 1;
---
> strict = COMPARE_STRICT;
818,819c900,901
< if (CLASSTYPE_TEMPLATE_INFO (t1) && CLASSTYPE_TEMPLATE_INFO (t2)
< && (CLASSTYPE_TI_TEMPLATE (t1) == CLASSTYPE_TI_TEMPLATE (t2)
---
> if (TYPE_TEMPLATE_INFO (t1) && TYPE_TEMPLATE_INFO (t2)
> && (TYPE_TI_TEMPLATE (t1) == TYPE_TI_TEMPLATE (t2)
821,825c903,916
< return comp_template_args (CLASSTYPE_TI_ARGS (t1),
< CLASSTYPE_TI_ARGS (t2));
< if (strict <= 0)
< goto look_hard;
< return 0;
---
> val = comp_template_args (TYPE_TI_ARGS (t1),
> TYPE_TI_ARGS (t2));
> look_hard:
> if ((strict & COMPARE_BASE) && DERIVED_FROM_P (t1, t2))
> {
> val = 1;
> break;
> }
> if ((strict & COMPARE_RELAXED) && DERIVED_FROM_P (t2, t1))
> {
> val = 1;
> break;
> }
> break;
843,844c934
< && compparms (TYPE_ARG_TYPES (t1),
< TYPE_ARG_TYPES (t2), strict));
---
> && compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2)));
851,878c941,948
< if (t1 == t2)
< {
< val = 1;
< break;
< }
< if (strict <= 0)
< {
< if (TREE_CODE (t1) == RECORD_TYPE && TREE_CODE (t2) == RECORD_TYPE)
< {
< int rval;
< look_hard:
< rval = t1 == t2 || DERIVED_FROM_P (t1, t2);
<
< if (rval)
< {
< val = 1;
< break;
< }
< if (strict < 0)
< {
< val = DERIVED_FROM_P (t2, t1);
< break;
< }
< }
< return 0;
< }
< else
< val = comptypes (t1, t2, strict);
---
> /* first, check whether the referred types match with the
> required level of strictness */
> val = comptypes (t1, t2, strict);
> if (val)
> break;
> if (TREE_CODE (t1) == RECORD_TYPE
> && TREE_CODE (t2) == RECORD_TYPE)
> goto look_hard;
887c957
< && compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2), strict));
---
> && compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2)));
891,892c961,964
< /* Target types must match incl. qualifiers. */
< val = comp_array_types (comptypes, t1, t2, strict);
---
> /* Target types must match incl. qualifiers. We use ORIG_STRICT
> here since this is the one place where
> COMPARE_REDECLARATION should be used. */
> val = comp_array_types (comptypes, t1, t2, orig_strict);
902c974
< return comptypes (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2), 1);
---
> return same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2));
909a982,1007
> /* Subroutine of comp_target-types. Make sure that the cv-quals change
> only in the same direction as the target type. */
>
> static int
> comp_cv_target_types (ttl, ttr, nptrs)
> tree ttl, ttr;
> int nptrs;
> {
> int t;
>
> if (!at_least_as_qualified_p (ttl, ttr)
> && !at_least_as_qualified_p (ttr, ttl))
> /* The qualifications are incomparable. */
> return 0;
>
> if (TYPE_MAIN_VARIANT (ttl) == TYPE_MAIN_VARIANT (ttr))
> return more_qualified_p (ttr, ttl) ? -1 : 1;
>
> t = comp_target_types (ttl, ttr, nptrs);
> if ((t == 1 && at_least_as_qualified_p (ttl, ttr))
> || (t == -1 && at_least_as_qualified_p (ttr, ttl)))
> return t;
>
> return 0;
> }
>
929c1027
< if (ttl == ttr)
---
> if (same_type_p (ttl, ttr))
935,936c1033,1039
< if (TREE_CODE (ttr) == POINTER_TYPE
< || (TREE_CODE (ttr) == REFERENCE_TYPE))
---
> if ((TREE_CODE (ttr) == POINTER_TYPE
> || TREE_CODE (ttr) == REFERENCE_TYPE)
> /* If we get a pointer with nptrs == 0, we don't allow any tweaking
> of the type pointed to. This is necessary for reference init
> semantics. We won't get here from a previous call with nptrs == 1;
> for multi-level pointers we end up in comp_ptr_ttypes. */
> && nptrs > 0)
943c1046
< if (nptrs > 0 && is_ptr)
---
> if (is_ptr)
974,992c1077
< /* Make sure that the cv-quals change only in the same direction as
< the target type. */
< {
< int t;
< int c = TYPE_READONLY (ttl) - TYPE_READONLY (ttr);
< int v = TYPE_VOLATILE (ttl) - TYPE_VOLATILE (ttr);
<
< if ((c > 0 && v < 0) || (c < 0 && v > 0))
< return 0;
<
< if (TYPE_MAIN_VARIANT (ttl) == TYPE_MAIN_VARIANT (ttr))
< return (c + v < 0) ? -1 : 1;
<
< t = comp_target_types (ttl, ttr, nptrs - 1);
< if ((t == 1 && c + v >= 0) || (t == -1 && c + v <= 0))
< return t;
<
< return 0;
< }
---
> return comp_cv_target_types (ttl, ttr, nptrs - 1);
996c1081
< return comp_array_types (comp_target_types, ttl, ttr, 0);
---
> return comp_array_types (comp_target_types, ttl, ttr, COMPARE_STRICT);
1004c1089
< if (comptypes (TREE_TYPE (ttl), TREE_TYPE (ttr), 1) == 0)
---
> if (!same_type_p (TREE_TYPE (ttl), TREE_TYPE (ttr)))
1027c1112
< if (comptypes (tr, tl, 0) == 0)
---
> if (!same_or_base_type_p (tr, tl))
1029c1114
< if (comptypes (tl, tr, 0))
---
> if (same_or_base_type_p (tl, tr))
1051a1137,1138
> int base;
>
1055,1061c1142,1171
< if (comptypes (TYPE_OFFSET_BASETYPE (ttr),
< TYPE_OFFSET_BASETYPE (ttl), 0))
< return comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs);
< else if (comptypes (TYPE_OFFSET_BASETYPE (ttl),
< TYPE_OFFSET_BASETYPE (ttr), 0)
< && comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs))
< return -1;
---
> if (same_or_base_type_p (TYPE_OFFSET_BASETYPE (ttr),
> TYPE_OFFSET_BASETYPE (ttl)))
> base = 1;
> else if (same_or_base_type_p (TYPE_OFFSET_BASETYPE (ttl),
> TYPE_OFFSET_BASETYPE (ttr)))
> {
> tree tmp = ttl;
> ttl = ttr;
> ttr = tmp;
> base = -1;
> }
> else
> return 0;
>
> ttl = TREE_TYPE (ttl);
> ttr = TREE_TYPE (ttr);
>
> if (TREE_CODE (ttl) == POINTER_TYPE
> || TREE_CODE (ttl) == ARRAY_TYPE)
> {
> if (comp_ptr_ttypes (ttl, ttr))
> return base;
> return 0;
> }
> else
> {
> if (comp_cv_target_types (ttl, ttr, nptrs) == 1)
> return base;
> return 0;
> }
1067c1177,1178
< if (comptypes (build_pointer_type (ttl), build_pointer_type (ttr), 0))
---
> if (same_or_base_type_p (build_pointer_type (ttl),
> build_pointer_type (ttr)))
1069c1180,1181
< if (comptypes (build_pointer_type (ttr), build_pointer_type (ttl), 0))
---
> if (same_or_base_type_p (build_pointer_type (ttr),
> build_pointer_type (ttl)))
1076a1189,1211
> /* Returns 1 if TYPE1 is at least as qualified as TYPE2. */
>
> int
> at_least_as_qualified_p (type1, type2)
> tree type1;
> tree type2;
> {
> /* All qualifiers for TYPE2 must also appear in TYPE1. */
> return ((CP_TYPE_QUALS (type1) & CP_TYPE_QUALS (type2))
> == CP_TYPE_QUALS (type2));
> }
>
> /* Returns 1 if TYPE1 is more qualified than TYPE2. */
>
> int
> more_qualified_p (type1, type2)
> tree type1;
> tree type2;
> {
> return (CP_TYPE_QUALS (type1) != CP_TYPE_QUALS (type2)
> && at_least_as_qualified_p (type1, type2));
> }
>
1085,1086c1220
< if (TYPE_READONLY (type1) == TYPE_READONLY (type2)
< && TYPE_VOLATILE (type1) == TYPE_VOLATILE (type2))
---
> if (CP_TYPE_QUALS (type1) == CP_TYPE_QUALS (type2))
1089,1090c1223
< if (TYPE_READONLY (type1) >= TYPE_READONLY (type2)
< && TYPE_VOLATILE (type1) >= TYPE_VOLATILE (type2))
---
> if (at_least_as_qualified_p (type1, type2))
1093,1094c1226
< if (TYPE_READONLY (type2) >= TYPE_READONLY (type1)
< && TYPE_VOLATILE (type2) >= TYPE_VOLATILE (type1))
---
> else if (at_least_as_qualified_p (type2, type1))
1171,1175c1303,1306
< /* Return 1 if two parameter type lists PARMS1 and PARMS2
< are equivalent in the sense that functions with those parameter types
< can have equivalent types.
< If either list is empty, we win.
< Otherwise, the two lists must be equivalent, element by element.
---
> /* Return 1 if two parameter type lists PARMS1 and PARMS2 are
> equivalent in the sense that functions with those parameter types
> can have equivalent types. The two lists must be equivalent,
> element by element.
1177c1308
< C++: See comment above about TYPE1, TYPE2.
---
> C++: See comment above about TYPE1, TYPE2. */
1179,1180d1309
< STRICT is no longer used. */
<
1182c1311
< compparms (parms1, parms2, strict)
---
> compparms (parms1, parms2)
1184d1312
< int strict;
1199c1327
< if (! comptypes (TREE_VALUE (t2), TREE_VALUE (t1), 1))
---
> if (!same_type_p (TREE_VALUE (t2), TREE_VALUE (t1)))
1230,1231c1358,1364
< cp_pedwarn ("ANSI C++ prohibits conversion from `(%#T)' to `(...)'",
< parms2);
---
> if (! flag_strict_prototype && t2 == void_list_node)
> /* t1 might be the arglist of a function pointer in extern "C"
> declared to take (), which we fudged to (...). Don't make the
> user pay for our mistake. */;
> else
> cp_pedwarn ("ANSI C++ prohibits conversion from `%#T' to `(...)'",
> parms2);
1253c1386
< if (comptypes (p1, p2, 1))
---
> if (same_type_p (p1, p2))
1277,1282c1410,1413
< if (IS_AGGR_TYPE (TREE_TYPE (p1)))
< {
< if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (p1)),
< TYPE_MAIN_VARIANT (TREE_TYPE (p2)), 1) == 0)
< return 0;
< }
---
> if (IS_AGGR_TYPE (TREE_TYPE (p1))
> && !same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (p1)),
> TYPE_MAIN_VARIANT (TREE_TYPE (p2))))
> return 0;
1344a1476
> #if HOST_BITS_PER_WIDE_INT >= 64
1346a1479
> #endif
1375a1509
> #if HOST_BITS_PER_WIDE_INT >= 64
1377a1512
> #endif
1496c1631
< && DECL_BIT_FIELD (TREE_OPERAND (e, 1)))
---
> && DECL_C_BIT_FIELD (TREE_OPERAND (e, 1)))
1506c1641
< else if (TREE_CODE (e) == TREE_LIST)
---
> else if (is_overloaded_fn (e))
1508,1513c1643,1644
< tree t = TREE_VALUE (e);
< if (t != NULL_TREE
< && ((TREE_TYPE (t)
< && TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
< || is_overloaded_fn (t)))
< pedwarn ("ANSI C++ forbids taking the sizeof a function type");
---
> pedwarn ("ANSI C++ forbids taking the sizeof a function type");
> return size_int (1);
1514a1646,1651
> else if (type_unknown_p (e))
> {
> incomplete_type_error (e, TREE_TYPE (e));
> return size_int (1);
> }
>
1580,1583c1717,1718
< /* Perform default promotions for C data used in expressions.
< Arrays and functions are converted to pointers;
< enumeral types or short or char, to int.
< In addition, manifest constants symbols are replaced by their values.
---
> /* Perform the array-to-pointer and function-to-pointer conversions
> for EXP.
1585c1720,1721
< C++: this will automatically bash references to their target type. */
---
> In addition, references are converted to rvalues and manifest
> constants are replaced by their values. */
1591,1592c1727,1728
< register tree type = TREE_TYPE (exp);
< register enum tree_code code = TREE_CODE (type);
---
> register tree type;
> register enum tree_code code;
1594,1597c1730,1731
< if (code == OFFSET_TYPE)
< {
< if (TREE_CODE (exp) == OFFSET_REF)
< return decay_conversion (resolve_offset_ref (exp));
---
> if (TREE_CODE (exp) == OFFSET_REF)
> exp = resolve_offset_ref (exp);
1599,1600c1733,1734
< type = TREE_TYPE (type);
< code = TREE_CODE (type);
---
> type = TREE_TYPE (exp);
> code = TREE_CODE (type);
1602,1608d1735
< if (type == unknown_type_node)
< {
< cp_pedwarn ("assuming & on overloaded member function");
< return build_unary_op (ADDR_EXPR, exp, 0);
< }
< }
<
1619,1620c1746,1754
< /* Replace a nonvolatile const static variable with its value. */
< else if (TREE_READONLY_DECL_P (exp))
---
> /* Replace a nonvolatile const static variable with its value. We
> don't do this for arrays, though; we want the address of the
> first element of the array, not the address of the first element
> of its initializing constant. We *do* replace variables that the
> user isn't really supposed to know about; this is a hack to deal
> with __PRETTY_FUNCTION__ and the like. */
> else if (TREE_READONLY_DECL_P (exp)
> && (code != ARRAY_TYPE
> || (TREE_CODE (exp) == VAR_DECL && DECL_IGNORED_P (exp))))
1634,1637d1767
< if (code == FUNCTION_TYPE)
< {
< return build_unary_op (ADDR_EXPR, exp, 0);
< }
1639,1642c1769,1771
< {
< cp_pedwarn ("assuming & on `%E'", exp);
< return build_unary_op (ADDR_EXPR, exp, 0);
< }
---
> my_friendly_abort (990506);
> if (code == FUNCTION_TYPE || is_overloaded_fn (exp))
> return build_unary_op (ADDR_EXPR, exp, 0);
1646d1774
< tree restype;
1648d1775
< int constp, volatilep;
1680,1686c1807
< constp = volatilep = 0;
< if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'r'
< || TREE_CODE_CLASS (TREE_CODE (exp)) == 'd')
< {
< constp = TREE_READONLY (exp);
< volatilep = TREE_THIS_VOLATILE (exp);
< }
---
> ptrtype = build_pointer_type (TREE_TYPE (type));
1688,1695d1808
< restype = TREE_TYPE (type);
< if (TYPE_READONLY (type) || TYPE_VOLATILE (type)
< || constp || volatilep)
< restype = cp_build_type_variant (restype,
< TYPE_READONLY (type) || constp,
< TYPE_VOLATILE (type) || volatilep);
< ptrtype = build_pointer_type (restype);
<
1747a1861,1884
> exp = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (exp)), exp);
>
> return exp;
> }
>
> /* Returns nonzero iff exp is a STRING_CST or the result of applying
> decay_conversion to one. */
>
> int
> string_conv_p (totype, exp, warn)
> tree totype, exp;
> int warn;
> {
> tree t;
>
> if (! flag_const_strings || TREE_CODE (totype) != POINTER_TYPE)
> return 0;
>
> t = TREE_TYPE (totype);
> if (!same_type_p (t, char_type_node)
> && !same_type_p (t, wchar_type_node))
> return 0;
>
> if (TREE_CODE (exp) == STRING_CST)
1749,1751c1886,1888
< tree type = build_type_variant
< (TREE_TYPE (exp), TREE_READONLY (exp), TREE_THIS_VOLATILE (exp));
< exp = build1 (ADDR_EXPR, build_pointer_type (type), exp);
---
> /* Make sure that we don't try to convert between char and wchar_t. */
> if (!same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (exp))), t))
> return 0;
1753c1890,1906
< return exp;
---
> else
> {
> /* Is this a string constant which has decayed to 'const char *'? */
> t = build_pointer_type (build_qualified_type (t, TYPE_QUAL_CONST));
> if (!same_type_p (TREE_TYPE (exp), t))
> return 0;
> STRIP_NOPS (exp);
> if (TREE_CODE (exp) != ADDR_EXPR
> || TREE_CODE (TREE_OPERAND (exp, 0)) != STRING_CST)
> return 0;
> }
>
> /* This warning is not very useful, as it complains about printf. */
> if (warn && warn_write_strings)
> cp_warning ("deprecated conversion from string constant to `%T'", totype);
>
> return 1;
1880c2033
< register tree basetype = TREE_TYPE (datum);
---
> register tree basetype;
1883a2037,2038
> tree field_type;
> int type_quals;
1886a2042,2045
>
> if (datum == error_mark_node
> || TREE_TYPE (datum) == error_mark_node)
> return error_mark_node;
1887a2047,2049
> /* BASETYPE holds the type of the class containing the COMPONENT. */
> basetype = TYPE_MAIN_VARIANT (TREE_TYPE (datum));
>
1921c2083
< basetype = TREE_TYPE (datum);
---
> basetype = TYPE_MAIN_VARIANT (TREE_TYPE (datum));
1927c2089
< basetype = TREE_TYPE (datum);
---
> basetype = TYPE_MAIN_VARIANT (TREE_TYPE (datum));
1951c2113
< if (!complete_type_or_else (basetype))
---
> if (!complete_type_or_else (basetype, datum))
1981,1982c2143,2144
< cp_pedwarn ("invalid use of type decl `%#D' as expression", component);
< return component;
---
> cp_error ("invalid use of type decl `%#D' as expression", component);
> return error_mark_node;
2005a2168,2172
> /* If the function is unique and static, we can resolve it
> now. Otherwise, we have to wait and see what context it is
> used in; a component_ref involving a non-static member
> function can only be used in a call (expr.ref). */
>
2007c2174
< && TREE_CODE (TREE_VALUE (fndecls)) != OVERLOAD)
---
> && TREE_CODE (TREE_VALUE (fndecls)) == FUNCTION_DECL)
2009,2015c2176
< tree access, fndecl;
<
< /* Unique, so use this one now. */
< basetype = TREE_PURPOSE (fndecls);
< fndecl = TREE_VALUE (fndecls);
< access = compute_access (TREE_PURPOSE (fndecls), fndecl);
< if (access == access_public_node)
---
> if (DECL_STATIC_FUNCTION_P (TREE_VALUE (fndecls)))
2017,2039c2178,2181
< if (DECL_VINDEX (fndecl)
< && ! resolves_to_fixed_type_p (datum, 0))
< {
< tree addr = build_unary_op (ADDR_EXPR, datum, 0);
< tree fntype = TREE_TYPE (fndecl);
<
< addr = convert_pointer_to (DECL_CONTEXT (fndecl),
< addr);
< datum = build_indirect_ref (addr, NULL_PTR);
< my_friendly_assert (datum != error_mark_node, 310);
< fndecl = build_vfn_ref (&addr, datum,
< DECL_VINDEX (fndecl));
< /* The type of fndecl is a function type,
< not a pointer-to-function type, since
< build_vfn_ref returns not the correct
< vtable slot, but the indirection of the
< correct vtable slot. */
< TREE_TYPE (fndecl) = fntype;
< }
< else
< mark_used (fndecl);
< return build (OFFSET_REF, TREE_TYPE (fndecl),
< datum, fndecl);
---
> tree fndecl = TREE_VALUE (fndecls);
> enforce_access (TREE_PURPOSE (fndecls), fndecl);
> mark_used (fndecl);
> return fndecl;
2041,2042d2182
< if (access == access_protected_node)
< cp_error ("member function `%D' is protected", fndecl);
2044,2045c2184,2191
< cp_error ("member function `%D' is private", fndecl);
< return error_mark_node;
---
> {
> /* A unique non-static member function. Other parts
> of the compiler expect something with
> unknown_type_node to be really overloaded, so
> let's oblige. */
> TREE_VALUE (fndecls)
> = scratch_ovl_cons (TREE_VALUE (fndecls), NULL_TREE);
> }
2047,2051d2192
< else
< {
< /* Just act like build_offset_ref, since the object does
< not matter unless we're actually calling the function. */
< tree t;
2053,2057c2194,2196
< t = build_tree_list (error_mark_node, fndecls);
< TREE_TYPE (t) = build_offset_type (basetype,
< unknown_type_node);
< return t;
< }
---
> ref = build (COMPONENT_REF, unknown_type_node,
> datum, TREE_VALUE (fndecls));
> return ref;
2084c2223
< while (!comptypes (base, basetype,1) && TYPE_NAME (base)
---
> while (!same_type_p (base, basetype) && TYPE_NAME (base)
2124c2263,2285
< ref = fold (build (COMPONENT_REF, TREE_TYPE (field),
---
> /* Compute the type of the field, as described in [expr.ref]. */
> type_quals = TYPE_UNQUALIFIED;
> field_type = TREE_TYPE (field);
> if (TREE_CODE (field_type) == REFERENCE_TYPE)
> /* The standard says that the type of the result should be the
> type referred to by the reference. But for now, at least, we
> do the conversion from reference type later. */
> ;
> else
> {
> type_quals = (CP_TYPE_QUALS (field_type)
> | CP_TYPE_QUALS (TREE_TYPE (datum)));
>
> /* A field is const (volatile) if the enclosing object, or the
> field itself, is const (volatile). But, a mutable field is
> not const, even within a const object. */
> if (DECL_LANG_SPECIFIC (field) && DECL_MUTABLE_P (field))
> type_quals &= ~TYPE_QUAL_CONST;
> if (!IS_SIGNATURE (field_type))
> field_type = cp_build_qualified_type (field_type, type_quals);
> }
>
> ref = fold (build (COMPONENT_REF, field_type,
2127c2288,2291
< if (TREE_READONLY (datum) || TREE_READONLY (field))
---
> /* Mark the expression const or volatile, as appropriate. Even
> though we've dealt with the type above, we still have to mark the
> expression itself. */
> if (type_quals & TYPE_QUAL_CONST)
2129c2293
< if (TREE_THIS_VOLATILE (datum) || TREE_THIS_VOLATILE (field))
---
> else if (type_quals & TYPE_QUAL_VOLATILE)
2131,2132d2294
< if (DECL_LANG_SPECIFIC (field) && DECL_MUTABLE_P (field))
< TREE_READONLY (ref) = 0;
2163c2325
< char *errorstring;
---
> const char *errorstring;
2180c2342
< char *errorstring;
---
> const char *errorstring;
2186a2349,2351
> if (ptr == current_class_ptr)
> return current_class_ref;
>
2191,2194c2356
< if (ptr == current_class_ptr)
< return current_class_ref;
<
< if (TREE_CODE (type) == POINTER_TYPE || TREE_CODE (type) == REFERENCE_TYPE)
---
> if (TYPE_PTR_P (type) || TREE_CODE (type) == REFERENCE_TYPE)
2195a2358,2367
> /* [expr.unary.op]
>
> If the type of the expression is "pointer to T," the type
> of the result is "T."
>
> We must use the canonical variant because certain parts of
> the back end, like fold, do pointer comparisons between
> types. */
> tree t = canonical_type_variant (TREE_TYPE (type));
>
2198,2203c2370,2372
< && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (pointer, 0)))
< == TYPE_MAIN_VARIANT (TREE_TYPE (type)))
< && (TREE_READONLY (TREE_OPERAND (pointer, 0))
< == TYPE_READONLY (TREE_TYPE (type)))
< && (TREE_THIS_VOLATILE (TREE_OPERAND (pointer, 0))
< == TYPE_VOLATILE (TREE_TYPE (type))))
---
> && same_type_p (t, TREE_TYPE (TREE_OPERAND (pointer, 0))))
> /* The POINTER was something like `&x'. We simplify `*&x' to
> `x'. */
2207,2209c2376
< tree t = TREE_TYPE (type);
< register tree ref = build1 (INDIRECT_REF,
< TYPE_MAIN_VARIANT (t), pointer);
---
> tree ref = build1 (INDIRECT_REF, t, pointer);
2214c2381,2382
< TREE_READONLY (ref) = TYPE_READONLY (t);
---
> TREE_READONLY (ref) = CP_TYPE_CONST_P (t);
> TREE_THIS_VOLATILE (ref) = CP_TYPE_VOLATILE_P (t);
2216c2384
< = (TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer)
---
> = (TREE_THIS_VOLATILE (ref) || TREE_SIDE_EFFECTS (pointer)
2218d2385
< TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
2224,2225c2391,2392
< else if (TYPE_PTRMEMFUNC_P (type))
< error ("invalid use of `%s' on pointer to member function", errorstring);
---
> else if (TYPE_PTRMEM_P (type) || TYPE_PTRMEMFUNC_P (type))
> error ("invalid use of `%s' on pointer to member", errorstring);
2329c2496
< type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (array)));
---
> type = TREE_TYPE (TREE_TYPE (array));
2334,2335c2501
< |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
< | TREE_READONLY (array));
---
> |= (CP_TYPE_CONST_P (type) | TREE_READONLY (array));
2337,2338c2503
< |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
< | TREE_SIDE_EFFECTS (array));
---
> |= (CP_TYPE_VOLATILE_P (type) | TREE_SIDE_EFFECTS (array));
2340,2345c2505
< |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
< /* This was added by rms on 16 Nov 91.
< It fixes vol struct foo *a; a->elts[1]
< in an inline function.
< Hope it doesn't break something else. */
< | TREE_THIS_VOLATILE (array));
---
> |= (CP_TYPE_VOLATILE_P (type) | TREE_THIS_VOLATILE (array));
2446a2607,2615
> if ((TREE_CODE (function) == FUNCTION_DECL
> && DECL_STATIC_FUNCTION_P (function))
> || (TREE_CODE (function) == TEMPLATE_DECL
> && DECL_STATIC_FUNCTION_P (DECL_RESULT (function))))
> return build_member_call(DECL_CONTEXT (function),
> template_id
> ? template_id : DECL_NAME (function),
> params);
>
2450a2620,2621
> || (TREE_CODE (function) == OVERLOAD
> && DECL_FUNCTION_MEMBER_P (OVL_CURRENT (function)))
2455,2461d2625
< if ((TREE_CODE (function) == FUNCTION_DECL
< && DECL_STATIC_FUNCTION_P (function))
< || (TREE_CODE (function) == TEMPLATE_DECL
< && DECL_STATIC_FUNCTION_P (DECL_RESULT (function))))
< return build_member_call
< (DECL_CONTEXT (function), DECL_NAME (function), params);
<
2470a2635,2637
> if (TREE_CODE (function) == OVERLOAD)
> function = OVL_CURRENT (function);
>
2522,2523c2689
< error ("object missing in call to method `%s'",
< IDENTIFIER_POINTER (function));
---
> cp_error ("object missing in call to method `%D'", function);
2527,2529c2693
< decl = build1 (NOP_EXPR, build_pointer_type (current_class_type),
< error_mark_node);
< decl = build_indirect_ref (decl, NULL_PTR);
---
> decl = build_dummy_object (current_class_type);
2541,2546c2705,2715
< /* Should we undo what was done in build_component_ref? */
< if (TREE_CODE (TREE_PURPOSE (TREE_OPERAND (function, 1))) == TREE_VEC)
< /* Get the name that build_component_ref hid. */
< function = DECL_NAME (TREE_VALUE (TREE_OPERAND (function, 1)));
< else
< function = TREE_PURPOSE (TREE_OPERAND (function, 1));
---
> /* Undo what we did in build_component_ref. */
> decl = TREE_OPERAND (function, 0);
> function = TREE_OPERAND (function, 1);
> function = DECL_NAME (OVL_CURRENT (function));
>
> if (template_id)
> {
> TREE_OPERAND (template_id, 0) = function;
> function = template_id;
> }
>
2669c2838
< tree instance;
---
> tree instance, basetype;
2679a2849
> basetype = TYPE_METHOD_BASETYPE (TREE_TYPE (fntype));
2681,2690d2850
< /* Promoting idx before saving it improves performance on RISC
< targets. Without promoting, the first compare used
< load-with-sign-extend, while the second used normal load then
< shift to sign-extend. An optimizer flaw, perhaps, but it's easier
< to make this change. */
< idx = save_expr (default_conversion
< (build_component_ref (function,
< index_identifier,
< NULL_TREE, 0)));
< e1 = build_binary_op (GT_EXPR, idx, integer_zero_node, 1);
2694c2854
< delta2 = DELTA2_FROM_PTRMEMFUNC (function);
---
> e3 = PFN_FROM_PTRMEMFUNC (function);
2696,2712c2856,2861
< /* Convert down to the right base, before using the instance. */
< instance
< = convert_pointer_to_real (TYPE_METHOD_BASETYPE (TREE_TYPE (fntype)),
< instance_ptr);
< if (instance == error_mark_node && instance_ptr != error_mark_node)
< return instance;
<
< vtbl = convert_pointer_to (ptr_type_node, instance);
< vtbl
< = build (PLUS_EXPR,
< build_pointer_type (build_pointer_type (vtable_entry_type)),
< vtbl, cp_convert (ptrdiff_type_node, delta2));
< vtbl = build_indirect_ref (vtbl, NULL_PTR);
< aref = build_array_ref (vtbl, build_binary_op (MINUS_EXPR,
< idx,
< integer_one_node, 1));
< if (! flag_vtable_thunks)
---
> if (TYPE_SIZE (basetype) != NULL_TREE
> && ! TYPE_VIRTUAL_P (basetype))
> /* If basetype doesn't have virtual functions, don't emit code to
> handle that case. */
> e1 = e3;
> else
2714c2863,2872
< aref = save_expr (aref);
---
> /* Promoting idx before saving it improves performance on RISC
> targets. Without promoting, the first compare used
> load-with-sign-extend, while the second used normal load then
> shift to sign-extend. An optimizer flaw, perhaps, but it's
> easier to make this change. */
> idx = save_expr (default_conversion
> (build_component_ref (function,
> index_identifier,
> NULL_TREE, 0)));
> e1 = build_binary_op (GE_EXPR, idx, integer_zero_node);
2716c2874,2881
< delta = build_binary_op
---
> /* Convert down to the right base, before using the instance. */
> instance = convert_pointer_to_real (basetype, instance_ptr);
> if (instance == error_mark_node && instance_ptr != error_mark_node)
> return instance;
>
> vtbl = convert_pointer_to (ptr_type_node, instance);
> delta2 = DELTA2_FROM_PTRMEMFUNC (function);
> vtbl = build
2718c2883,2896
< build_conditional_expr (e1, build_component_ref (aref,
---
> build_pointer_type (build_pointer_type (vtable_entry_type)),
> vtbl, cp_convert (ptrdiff_type_node, delta2));
> vtbl = build_indirect_ref (vtbl, NULL_PTR);
> aref = build_array_ref (vtbl, build_binary_op (MINUS_EXPR,
> idx,
> integer_one_node));
> if (! flag_vtable_thunks)
> {
> aref = save_expr (aref);
>
> delta = build_binary_op
> (PLUS_EXPR,
> build_conditional_expr (e1,
> build_component_ref (aref,
2721,2722c2899,2914
< integer_zero_node),
< delta, 1);
---
> integer_zero_node),
> delta);
> }
>
> if (flag_vtable_thunks)
> e2 = aref;
> else
> e2 = build_component_ref (aref, pfn_identifier, NULL_TREE, 0);
> TREE_TYPE (e2) = TREE_TYPE (e3);
> e1 = build_conditional_expr (e1, e2, e3);
>
> /* Make sure this doesn't get evaluated first inside one of the
> branches of the COND_EXPR. */
> if (TREE_CODE (instance_ptr) == SAVE_EXPR)
> e1 = build (COMPOUND_EXPR, TREE_TYPE (e1),
> instance_ptr, e1);
2727,2730d2918
< if (flag_vtable_thunks)
< e2 = aref;
< else
< e2 = build_component_ref (aref, pfn_identifier, NULL_TREE, 0);
2732,2735d2919
< e3 = PFN_FROM_PTRMEMFUNC (function);
< TREE_TYPE (e2) = TREE_TYPE (e3);
< e1 = build_conditional_expr (e1, e2, e3);
<
2742,2747d2925
<
< /* Make sure this doesn't get evaluated first inside one of the
< branches of the COND_EXPR. */
< if (TREE_CODE (instance_ptr) == SAVE_EXPR)
< function = build (COMPOUND_EXPR, TREE_TYPE (function),
< instance_ptr, function);
2832c3010
< coerced_params = convert_arguments (NULL_TREE, TYPE_ARG_TYPES (fntype),
---
> coerced_params = convert_arguments (TYPE_ARG_TYPES (fntype),
2835c3013
< coerced_params = convert_arguments (NULL_TREE, TYPE_ARG_TYPES (fntype),
---
> coerced_params = convert_arguments (TYPE_ARG_TYPES (fntype),
2879c3057
< if (value_type == void_type_node)
---
> if (TREE_CODE (value_type) == VOID_TYPE)
2901,2906d3078
< RETURN_LOC is the location of the return value, if known, NULL_TREE
< otherwise. This is useful in the case where we can avoid creating
< a temporary variable in the case where we can initialize the return
< value directly. If we are not eliding constructors, then we set this
< to NULL_TREE to avoid this avoidance.
<
2920,2921c3092,3093
< convert_arguments (return_loc, typelist, values, fndecl, flags)
< tree return_loc, typelist, values, fndecl;
---
> convert_arguments (typelist, values, fndecl, flags)
> tree typelist, values, fndecl;
2926c3098
< char *called_thing = 0;
---
> const char *called_thing = 0;
2929,2931d3100
< if (! flag_elide_constructors)
< return_loc = 0;
<
2963c3132
< cp_error_at ("too many arguments to %s `%+D'", called_thing,
---
> cp_error_at ("too many arguments to %s `%+#D'", called_thing,
2976,3000c3145
< /* The tree type of the parameter being passed may not yet be
< known. In this case, its type is TYPE_UNKNOWN, and will
< be instantiated by the type given by TYPE. If TYPE
< is also NULL, the tree type of VAL is ERROR_MARK_NODE. */
< if (type && type_unknown_p (val))
< val = require_instantiated_type (type, val, integer_zero_node);
< else if (type_unknown_p (val))
< {
< /* Strip the `&' from an overloaded FUNCTION_DECL. */
< if (TREE_CODE (val) == ADDR_EXPR)
< val = TREE_OPERAND (val, 0);
< if (really_overloaded_fn (val))
< cp_error ("insufficient type information to resolve address of overloaded function `%D'",
< DECL_NAME (get_first_fn (val)));
< else
< error ("insufficient type information in parameter list");
< val = integer_zero_node;
< }
< else if (TREE_CODE (val) == OFFSET_REF
< && TREE_CODE (TREE_TYPE (val)) == METHOD_TYPE)
< {
< /* This is unclean. Should be handled elsewhere. */
< val = build_unary_op (ADDR_EXPR, val, 0);
< }
< else if (TREE_CODE (val) == OFFSET_REF)
---
> if (TREE_CODE (val) == OFFSET_REF)
3016,3017d3160
<
< val = require_complete_type (val);
3036c3179
< (return_loc, type, val, flags,
---
> (NULL_TREE, type, val, flags,
3073,3075c3216,3219
< tree type = TREE_VALUE (typetail);
< tree val = TREE_PURPOSE (typetail);
< tree parmval = convert_default_arg (type, val);
---
> tree parmval
> = convert_default_arg (TREE_VALUE (typetail),
> TREE_PURPOSE (typetail),
> fndecl);
3091,3093c3235,3236
< char *buf = (char *)alloca (32 + strlen (called_thing));
< sprintf (buf, "too few arguments to %s `%%#D'", called_thing);
< cp_error_at (buf, fndecl);
---
> cp_error_at ("too few arguments to %s `%+#D'",
> called_thing, fndecl);
3120c3263
< build_binary_op (code, arg1, arg2, convert_p)
---
> build_binary_op (code, arg1, arg2)
3123d3265
< int convert_p;
3125,3157c3267
< tree args[2];
<
< args[0] = arg1;
< args[1] = arg2;
<
< if (convert_p)
< {
< tree type0, type1;
< args[0] = decay_conversion (args[0]);
< args[1] = decay_conversion (args[1]);
<
< if (args[0] == error_mark_node || args[1] == error_mark_node)
< return error_mark_node;
<
< type0 = TREE_TYPE (args[0]);
< type1 = TREE_TYPE (args[1]);
<
< if (type_unknown_p (args[0]))
< {
< args[0] = instantiate_type (type1, args[0], 1);
< args[0] = decay_conversion (args[0]);
< }
< else if (type_unknown_p (args[1]))
< {
< args[1] = require_instantiated_type (type0, args[1],
< error_mark_node);
< args[1] = decay_conversion (args[1]);
< }
<
< if (IS_AGGR_TYPE (type0) || IS_AGGR_TYPE (type1))
< my_friendly_abort (754867);
< }
< return build_binary_op_nodefault (code, args[0], args[1], code);
---
> return build_binary_op_nodefault (code, arg1, arg2, code);
3246a3357,3382
> /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue. */
> STRIP_TYPE_NOPS (op0);
> STRIP_TYPE_NOPS (op1);
>
> /* DTRT if one side is an overloaded function, but complain about it. */
> if (type_unknown_p (op0))
> {
> tree t = instantiate_type (TREE_TYPE (op1), op0, 0);
> if (t != error_mark_node)
> {
> cp_pedwarn ("assuming cast to `%T' from overloaded function",
> TREE_TYPE (t));
> op0 = t;
> }
> }
> if (type_unknown_p (op1))
> {
> tree t = instantiate_type (TREE_TYPE (op0), op1, 0);
> if (t != error_mark_node)
> {
> cp_pedwarn ("assuming cast to `%T' from overloaded function",
> TREE_TYPE (t));
> op1 = t;
> }
> }
>
3255,3258d3390
< /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue. */
< STRIP_TYPE_NOPS (op0);
< STRIP_TYPE_NOPS (op1);
<
3531,3532c3663
< && (TYPE_PTRMEMFUNC_FN_TYPE (type0)
< == TYPE_PTRMEMFUNC_FN_TYPE (type1)))
---
> && same_type_p (type0, type1))
3551,3553c3682,3684
< integer_one_node, 1);
< e1 = build_binary_op (EQ_EXPR, index0, index1, 1);
< e2 = build_binary_op (NE_EXPR, index1, integer_neg_one_node, 1);
---
> integer_one_node);
> e1 = build_binary_op (EQ_EXPR, index0, index1);
> e2 = build_binary_op (NE_EXPR, index1, integer_neg_one_node);
3555,3559c3686,3691
< build_binary_op (EQ_EXPR, delta20, delta21, 1),
< 1);
< e3 = build_binary_op (EQ_EXPR, pfn0, pfn1, 1);
< e2 = build_binary_op (TRUTH_ORIF_EXPR, e2, e3, 1);
< e2 = build_binary_op (TRUTH_ANDIF_EXPR, e1, e2, 1);
---
> build_binary_op (EQ_EXPR, delta20, delta21));
> /* We can't use build_binary_op for this cmp because it would get
> confused by the ptr to method types and think we want pmfs. */
> e3 = build (EQ_EXPR, boolean_type_node, pfn0, pfn1);
> e2 = build_binary_op (TRUTH_ORIF_EXPR, e2, e3);
> e2 = build_binary_op (TRUTH_ANDIF_EXPR, e1, e2);
3562c3694
< return build_binary_op (EQ_EXPR, e2, integer_zero_node, 1);
---
> return build_binary_op (EQ_EXPR, e2, integer_zero_node);
3565c3697
< && TYPE_PTRMEMFUNC_FN_TYPE (type0) == type1)
---
> && same_type_p (TYPE_PTRMEMFUNC_FN_TYPE (type0), type1))
3575c3707
< = build_binary_op (MINUS_EXPR, integer_zero_node, integer_one_node, 1);
---
> = build_binary_op (MINUS_EXPR, integer_zero_node, integer_one_node);
3600,3601c3732,3733
< e1 = build_binary_op (EQ_EXPR, index0, index1, 1);
< e2 = build_binary_op (NE_EXPR, index1, integer_neg_one_node, 1);
---
> e1 = build_binary_op (EQ_EXPR, index0, index1);
> e2 = build_binary_op (NE_EXPR, index1, integer_neg_one_node);
3603,3607c3735,3740
< build_binary_op (EQ_EXPR, delta20, delta21, 1),
< 1);
< e3 = build_binary_op (EQ_EXPR, pfn0, op1, 1);
< e2 = build_binary_op (TRUTH_ORIF_EXPR, e2, e3, 1);
< e2 = build_binary_op (TRUTH_ANDIF_EXPR, e1, e2, 1);
---
> build_binary_op (EQ_EXPR, delta20, delta21));
> /* We can't use build_binary_op for this cmp because it would get
> confused by the ptr to method types and think we want pmfs. */
> e3 = build (EQ_EXPR, boolean_type_node, pfn0, op1);
> e2 = build_binary_op (TRUTH_ORIF_EXPR, e2, e3);
> e2 = build_binary_op (TRUTH_ANDIF_EXPR, e1, e2);
3610c3743
< return build_binary_op (EQ_EXPR, e2, integer_zero_node, 1);
---
> return build_binary_op (EQ_EXPR, e2, integer_zero_node);
3613,3616c3746,3747
< && TYPE_PTRMEMFUNC_FN_TYPE (type1) == type0)
< {
< return build_binary_op (code, op1, op0, 1);
< }
---
> && same_type_p (TYPE_PTRMEMFUNC_FN_TYPE (type1), type0))
> return build_binary_op (code, op1, op0);
3829,3830c3960
< if (flag_int_enum_equivalence == 0
< && TREE_CODE (TREE_TYPE (orig_op0)) == ENUMERAL_TYPE
---
> if (TREE_CODE (TREE_TYPE (orig_op0)) == ENUMERAL_TYPE
3942a4073,4091
> /* Issue warnings about peculiar, but legal, uses of NULL. */
> if (/* It's reasonable to use pointer values as operands of &&
> and ||, so NULL is no exception. */
> !(code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR)
> && (/* If OP0 is NULL and OP1 is not a pointer, or vice versa. */
> (orig_op0 == null_node
> && TREE_CODE (TREE_TYPE (op1)) != POINTER_TYPE)
> /* Or vice versa. */
> || (orig_op1 == null_node
> && TREE_CODE (TREE_TYPE (op0)) != POINTER_TYPE)
> /* Or, both are NULL and the operation was not a comparison. */
> || (orig_op0 == null_node && orig_op1 == null_node
> && code != EQ_EXPR && code != NE_EXPR)))
> /* Some sort of arithmetic operation involving NULL was
> performed. Note that pointer-difference and pointer-addition
> have already been handled above, and so we don't end up here in
> that case. */
> cp_warning ("NULL used in arithmetic");
>
3948a4098,4100
>
> if (op0 == error_mark_node || op1 == error_mark_node)
> return error_mark_node;
3984c4136
< if (!complete_type_or_else (result_type))
---
> if (!complete_type_or_else (result_type, ptrop))
4034c4186
< ptrop = build_binary_op (subcode, ptrop, TREE_OPERAND (intop, 1), 1);
---
> ptrop = build_binary_op (subcode, ptrop, TREE_OPERAND (intop, 1));
4051,4052c4203
< size_exp),
< 1));
---
> size_exp)));
4076c4227
< if (!complete_type_or_else (target_type))
---
> if (!complete_type_or_else (target_type, NULL_TREE))
4095c4246
< cp_convert (restype, op1), 1);
---
> cp_convert (restype, op1));
4119c4270
< Called by `build_unary_op' and `build_up_reference'.
---
> Called by `build_unary_op'.
4122,4124c4273
< ARGTYPE is the pointer type that this address should have.
< MSG is an error message to print if this COMPONENT_REF is not
< addressable (such as a bitfield). */
---
> ARGTYPE is the pointer type that this address should have. */
4126,4127c4275,4276
< tree
< build_component_addr (arg, argtype, msg)
---
> static tree
> build_component_addr (arg, argtype)
4129d4277
< char *msg;
4135c4283,4285
< if (DECL_BIT_FIELD (field))
---
> my_friendly_assert (TREE_CODE (field) == FIELD_DECL, 981018);
>
> if (DECL_C_BIT_FIELD (field))
4137c4287,4288
< error (msg, IDENTIFIER_POINTER (DECL_NAME (field)));
---
> cp_error ("attempt to take address of bit-field structure member `%D'",
> field);
4239c4390
< char *errstring = NULL;
---
> const char *errstring = NULL;
4368c4519
< if (TYPE_READONLY (TREE_TYPE (arg))
---
> if (CP_TYPE_CONST_P (TREE_TYPE (arg))
4495c4646
< argtype = TREE_TYPE (arg);
---
> argtype = lvalue_type (arg);
4500c4651
< build_pointer_type (TREE_TYPE (TREE_TYPE (arg))), arg);
---
> build_pointer_type (TREE_TYPE (argtype)), arg);
4536c4687
< TREE_OPERAND (arg, 1), 1);
---
> TREE_OPERAND (arg, 1));
4552,4556c4703,4704
< if (TREE_CODE (arg) == OVERLOAD
< || (TREE_CODE (arg) == OFFSET_REF
< && TREE_CODE (TREE_OPERAND (arg, 1)) == TEMPLATE_ID_EXPR))
< return build1 (ADDR_EXPR, unknown_type_node, arg);
< else if (TREE_CODE (arg) == TREE_LIST)
---
> if (TREE_CODE (arg) == COMPONENT_REF && type_unknown_p (arg)
> && OVL_NEXT (TREE_OPERAND (arg, 1)) == NULL_TREE)
4558,4581c4706,4708
< if (TREE_CODE (TREE_VALUE (arg)) == FUNCTION_DECL)
< /* Unique overloaded non-member function. */
< return build_unary_op (ADDR_EXPR, TREE_VALUE (arg), 0);
< if (TREE_CHAIN (arg) == NULL_TREE
< && TREE_CODE (TREE_VALUE (arg)) == TREE_LIST
< && TREE_CODE (TREE_VALUE (TREE_VALUE (arg))) != OVERLOAD)
< /* Unique overloaded member function. */
< return build_unary_op (ADDR_EXPR, TREE_VALUE (TREE_VALUE (arg)),
< 0);
< return build1 (ADDR_EXPR, unknown_type_node, arg);
< }
< else if (TREE_CODE (arg) == TEMPLATE_ID_EXPR)
< {
< tree targs;
< tree fn;
<
< /* We don't require a match here; it's possible that the
< context (like a cast to a particular type) will resolve
< the particular choice of template. */
< fn = determine_specialization (arg,
< NULL_TREE,
< &targs,
< 0,
< 0);
---
> /* They're trying to take the address of a unique non-static
> member function. This is ill-formed, but let's try to DTRT. */
> tree base, name;
4583,4588c4710,4715
< if (fn)
< {
< fn = instantiate_template (fn, targs);
< mark_addressable (fn);
< return build_unary_op (ADDR_EXPR, fn, 0);
< }
---
> if (current_class_type
> && TREE_OPERAND (arg, 0) == current_class_ref)
> /* An expression like &memfn. */
> pedwarn ("taking the address of a non-static member function");
> else
> pedwarn ("taking the address of a bound member function");
4590c4717,4722
< return build1 (ADDR_EXPR, unknown_type_node, arg);
---
> base = TREE_TYPE (TREE_OPERAND (arg, 0));
> name = DECL_NAME (OVL_CURRENT (TREE_OPERAND (arg, 1)));
>
> cp_pedwarn (" to form a pointer to member function, say `&%T::%D'",
> base, name);
> arg = build_offset_ref (base, name);
4592a4725,4727
> if (type_unknown_p (arg))
> return build1 (ADDR_EXPR, unknown_type_node, arg);
>
4628,4638c4763,4764
< /* Ordinary case; arg is a COMPONENT_REF or a decl. */
< /* If the lvalue is const or volatile,
< merge that into the type that the address will point to. */
< if (TREE_CODE_CLASS (TREE_CODE (arg)) == 'd'
< || TREE_CODE_CLASS (TREE_CODE (arg)) == 'r')
< {
< if (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg))
< argtype = cp_build_type_variant (argtype,
< TREE_READONLY (arg),
< TREE_THIS_VOLATILE (arg));
< }
---
> if (argtype != error_mark_node)
> argtype = build_pointer_type (argtype);
4640,4641d4765
< argtype = build_pointer_type (argtype);
<
4649,4651c4773
< addr = build_component_addr
< (arg, argtype,
< "attempt to take address of bit-field structure member `%s'");
---
> addr = build_component_addr (arg, argtype);
4653c4775
< addr = build1 (code, argtype, arg);
---
> addr = build1 (ADDR_EXPR, argtype, arg);
4786d4907
< tree offset;
4789,4798c4910,4915
< && (TREE_CODE (TREE_OPERAND (arg, 0)) != NOP_EXPR
< || (TREE_OPERAND (TREE_OPERAND (arg, 0), 0)
< != error_mark_node)))
< if (TREE_CODE (t) != FIELD_DECL)
< {
< /* Don't know if this should return address to just
< _DECL, or actual address resolved in this expression. */
< sorry ("address of bound pointer-to-member expression");
< return error_mark_node;
< }
---
> && ! is_dummy_object (TREE_OPERAND (arg, 0))
> && TREE_CODE (t) != FIELD_DECL)
> {
> cp_error ("taking address of bound pointer-to-member expression");
> return error_mark_node;
> }
4800,4810d4916
< /* Add in the offset to the field. */
< offset = convert (sizetype,
< size_binop (EASY_DIV_EXPR,
< DECL_FIELD_BITPOS (t),
< size_int (BITS_PER_UNIT)));
<
< /* We offset all pointer to data members by 1 so that we can
< distinguish between a null pointer to data member and the first
< data member of a structure. */
< offset = size_binop (PLUS_EXPR, offset, size_int (1));
<
4814c4920,4921
< return cp_convert (type, offset);
---
> t = make_ptrmem_cst (type, TREE_OPERAND (arg, 1));
> return t;
4892c4999,5000
< rest_of_decl_compilation (x, 0, IDENTIFIER_LOCAL_VALUE (x) == 0,
---
> rest_of_decl_compilation (x, 0,
> !DECL_FUNCTION_SCOPE_P (x),
4976a5085,5092
> type1 = TREE_TYPE (op1);
> code1 = TREE_CODE (type1);
> type2 = TREE_TYPE (op2);
> code2 = TREE_CODE (type2);
> if (op1 == error_mark_node || op2 == error_mark_node
> || type1 == error_mark_node || type2 == error_mark_node)
> return error_mark_node;
>
4982,4988d5097
< op1 = require_instantiated_type (TREE_TYPE (op2), op1, error_mark_node);
< if (op1 == error_mark_node)
< return error_mark_node;
< op2 = require_instantiated_type (TREE_TYPE (op1), op2, error_mark_node);
< if (op2 == error_mark_node)
< return error_mark_node;
<
4990,4994d5098
< type1 = TREE_TYPE (op1);
< code1 = TREE_CODE (type1);
< type2 = TREE_TYPE (op2);
< code2 = TREE_CODE (type2);
<
5033,5036c5137,5139
< type1 = cp_build_type_variant
< (type1,
< TREE_READONLY (op1) || TREE_READONLY (op2),
< TREE_THIS_VOLATILE (op1) || TREE_THIS_VOLATILE (op2));
---
> type1 = cp_build_qualified_type
> (type1, (CP_TYPE_QUALS (TREE_TYPE (op1))
> | CP_TYPE_QUALS (TREE_TYPE (op2))));
5092c5195
< && comptypes (type1, type2, -1))
---
> && comptypes (type1, type2, COMPARE_BASE | COMPARE_RELAXED))
5109,5112c5212,5215
< result_type = cp_build_type_variant
< (type1,
< TREE_READONLY (op1) || TREE_READONLY (op2),
< TREE_THIS_VOLATILE (op1) || TREE_THIS_VOLATILE (op2));
---
> result_type =
> cp_build_qualified_type (type1,
> CP_TYPE_QUALS (TREE_TYPE (op1))
> | CP_TYPE_QUALS (TREE_TYPE (op2)));
5146c5249
< else if (comptypes (type2, type1, 0))
---
> else if (same_or_base_type_p (type2, type1))
5185a5289,5292
> if (type2 == unknown_type_node)
> result_type = type1;
> else if (type1 == unknown_type_node)
> result_type = type2;
5205c5312,5315
< (build_type_variant (TREE_TYPE (type2), 1, 1));
---
> (cp_build_qualified_type (TREE_TYPE (type2),
> TYPE_QUAL_CONST
> | TYPE_QUAL_VOLATILE
> | TYPE_QUAL_RESTRICT));
5208c5318
< tmp = build_type_conversion (CONVERT_EXPR, tmp, op1, 0);
---
> tmp = build_type_conversion (tmp, op1, 0);
5227c5337,5340
< (build_type_variant (TREE_TYPE (type1), 1, 1));
---
> (cp_build_qualified_type (TREE_TYPE (type1),
> TYPE_QUAL_CONST
> | TYPE_QUAL_VOLATILE
> | TYPE_QUAL_RESTRICT));
5231c5344
< tmp = build_type_conversion (CONVERT_EXPR, tmp, op2, 0);
---
> tmp = build_type_conversion (tmp, op2, 0);
5322a5436
> tree first;
5341a5456,5460
> first = TREE_VALUE (list);
> first = require_complete_type_in_void (first);
> if (first == error_mark_node)
> return error_mark_node;
>
5342a5462,5463
> if (rest == error_mark_node)
> return error_mark_node;
5345c5466
< if (! TREE_SIDE_EFFECTS (TREE_VALUE (list)) && ! pedantic)
---
> if (! TREE_SIDE_EFFECTS (first) && ! pedantic)
5349c5470
< break_out_cleanups (TREE_VALUE (list)), rest);
---
> break_out_cleanups (first), rest);
5382,5388d5502
< if (type_unknown_p (expr))
< {
< expr = instantiate_type (type, expr, 1);
< if (expr == error_mark_node)
< return error_mark_node;
< }
<
5412,5415c5526,5527
< && (TYPE_READONLY (TREE_TYPE (type))
< >= TYPE_READONLY (TREE_TYPE (intype)))
< && (TYPE_VOLATILE (TREE_TYPE (type))
< >= TYPE_VOLATILE (TREE_TYPE (intype)))
---
> && at_least_as_qualified_p (TREE_TYPE (type),
> TREE_TYPE (intype))
5422,5427c5534,5537
< if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))),
< TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (intype))), 1)
< && (TYPE_READONLY (TREE_TYPE (TREE_TYPE (type)))
< >= TYPE_READONLY (TREE_TYPE (TREE_TYPE (intype))))
< && (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (type)))
< >= TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (intype))))
---
> if (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))),
> TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (intype))))
> && at_least_as_qualified_p (TREE_TYPE (TREE_TYPE (type)),
> TREE_TYPE (TREE_TYPE (intype)))
5476,5482d5585
< if (type_unknown_p (expr))
< {
< expr = instantiate_type (type, expr, 1);
< if (expr == error_mark_node)
< return error_mark_node;
< }
<
5500c5603,5604
< else if (comptypes (TYPE_MAIN_VARIANT (intype), TYPE_MAIN_VARIANT (type), 1))
---
> else if (same_type_p (TYPE_MAIN_VARIANT (intype),
> TYPE_MAIN_VARIANT (type)))
5531c5635
< || (TYPE_PTRFN_P (type) && TYPE_PTROBV_P (intype)))
---
> || (TYPE_PTRFN_P (intype) && TYPE_PTROBV_P (type)))
5565a5670,5683
> if (!POINTER_TYPE_P (type))
> {
> cp_error ("`%T' is not a pointer, reference, or pointer-to-data-member type",
> type);
> cp_error ("as required by const_cast");
> }
> else if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
> {
> cp_error ("`%T' is a pointer or reference to a function type",
> type);
> cp_error ("which is forbidden by const_cast");
> return error_mark_node;
> }
>
5577,5583d5694
< if (type_unknown_p (expr))
< {
< expr = instantiate_type (type, expr, 1);
< if (expr == error_mark_node)
< return error_mark_node;
< }
<
5586c5697
< if (comptypes (TYPE_MAIN_VARIANT (intype), TYPE_MAIN_VARIANT (type), 1))
---
> if (same_type_p (TYPE_MAIN_VARIANT (intype), TYPE_MAIN_VARIANT (type)))
5621a5733
> tree otype;
5633,5635c5745
< if (TREE_TYPE (expr)
< && TREE_CODE (TREE_TYPE (expr)) == OFFSET_TYPE
< && TREE_CODE (type) != OFFSET_TYPE)
---
> if (TREE_CODE (value) == OFFSET_REF)
5676,5688c5786,5793
< if (TREE_CODE (type) == VOID_TYPE)
< value = build1 (CONVERT_EXPR, type, value);
< else if (TREE_TYPE (value) == NULL_TREE
< || type_unknown_p (value))
< {
< value = instantiate_type (type, value, 1);
< /* Did we lose? */
< if (value == error_mark_node)
< return error_mark_node;
< }
< else
< {
< tree otype;
---
> /* Convert functions and arrays to pointers and
> convert references to their expanded types,
> but don't convert any other types. If, however, we are
> casting to a class type, there's no reason to do this: the
> cast will only succeed if there is a converting constructor,
> and the default conversions will be done at that point. In
> fact, doing the default conversion here is actually harmful
> in cases like this:
5690,5697c5795,5796
< /* Convert functions and arrays to pointers and
< convert references to their expanded types,
< but don't convert any other types. If, however, we are
< casting to a class type, there's no reason to do this: the
< cast will only succeed if there is a converting constructor,
< and the default conversions will be done at that point. In
< fact, doing the default conversion here is actually harmful
< in cases like this:
---
> typedef int A[2];
> struct S { S(const A&); };
5699,5720c5798,5815
< typedef int A[2];
< struct S { S(const A&); };
<
< since we don't want the array-to-pointer conversion done. */
< if (!IS_AGGR_TYPE (type))
< {
< if (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE
< || (TREE_CODE (TREE_TYPE (value)) == METHOD_TYPE
< /* Don't do the default conversion if we want a
< pointer to a function. */
< && ! (TREE_CODE (type) == POINTER_TYPE
< && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE))
< || TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
< || TREE_CODE (TREE_TYPE (value)) == REFERENCE_TYPE)
< value = default_conversion (value);
< }
< else if (TREE_CODE (TREE_TYPE (value)) == REFERENCE_TYPE)
< /* However, even for class types, we still need to strip away
< the reference type, since the call to convert_force below
< does not expect the input expression to be of reference
< type. */
< value = convert_from_reference (value);
---
> since we don't want the array-to-pointer conversion done. */
> if (!IS_AGGR_TYPE (type))
> {
> if (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE
> || (TREE_CODE (TREE_TYPE (value)) == METHOD_TYPE
> /* Don't do the default conversion on a ->* expression. */
> && ! (TREE_CODE (type) == POINTER_TYPE
> && bound_pmf_p (value)))
> || TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
> || TREE_CODE (TREE_TYPE (value)) == REFERENCE_TYPE)
> value = default_conversion (value);
> }
> else if (TREE_CODE (TREE_TYPE (value)) == REFERENCE_TYPE)
> /* However, even for class types, we still need to strip away
> the reference type, since the call to convert_force below
> does not expect the input expression to be of reference
> type. */
> value = convert_from_reference (value);
5722c5817
< otype = TREE_TYPE (value);
---
> otype = TREE_TYPE (value);
5724c5819
< /* Optionally warn about potentially worrisome casts. */
---
> /* Optionally warn about potentially worrisome casts. */
5726,5738c5821,5826
< if (warn_cast_qual
< && TREE_CODE (type) == POINTER_TYPE
< && TREE_CODE (otype) == POINTER_TYPE)
< {
< /* For C++ we make these regular warnings, rather than
< softening them into pedwarns. */
< if (TYPE_VOLATILE (TREE_TYPE (otype))
< && ! TYPE_VOLATILE (TREE_TYPE (type)))
< warning ("cast discards `volatile' from pointer target type");
< if (TYPE_READONLY (TREE_TYPE (otype))
< && ! TYPE_READONLY (TREE_TYPE (type)))
< warning ("cast discards `const' from pointer target type");
< }
---
> if (warn_cast_qual
> && TREE_CODE (type) == POINTER_TYPE
> && TREE_CODE (otype) == POINTER_TYPE
> && !at_least_as_qualified_p (TREE_TYPE (type),
> TREE_TYPE (otype)))
> cp_warning ("cast discards qualifiers from pointer target type");
5740,5747c5828,5835
< /* Warn about possible alignment problems. */
< if (STRICT_ALIGNMENT && warn_cast_align
< && TREE_CODE (type) == POINTER_TYPE
< && TREE_CODE (otype) == POINTER_TYPE
< && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE
< && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
< && TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype)))
< warning ("cast increases required alignment of target type");
---
> /* Warn about possible alignment problems. */
> if (STRICT_ALIGNMENT && warn_cast_align
> && TREE_CODE (type) == POINTER_TYPE
> && TREE_CODE (otype) == POINTER_TYPE
> && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE
> && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
> && TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype)))
> warning ("cast increases required alignment of target type");
5750,5755c5838,5843
< /* We should see about re-enabling these, they seem useful to
< me. */
< if (TREE_CODE (type) == INTEGER_TYPE
< && TREE_CODE (otype) == POINTER_TYPE
< && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
< warning ("cast from pointer to integer of different size");
---
> /* We should see about re-enabling these, they seem useful to
> me. */
> if (TREE_CODE (type) == INTEGER_TYPE
> && TREE_CODE (otype) == POINTER_TYPE
> && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
> warning ("cast from pointer to integer of different size");
5757,5763c5845,5851
< if (TREE_CODE (type) == POINTER_TYPE
< && TREE_CODE (otype) == INTEGER_TYPE
< && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
< /* Don't warn about converting 0 to pointer,
< provided the 0 was explicit--not cast or made by folding. */
< && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value)))
< warning ("cast to pointer from integer of different size");
---
> if (TREE_CODE (type) == POINTER_TYPE
> && TREE_CODE (otype) == INTEGER_TYPE
> && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
> /* Don't warn about converting 0 to pointer,
> provided the 0 was explicit--not cast or made by folding. */
> && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value)))
> warning ("cast to pointer from integer of different size");
5766,5772c5854,5866
< if (TREE_CODE (type) == REFERENCE_TYPE)
< value = (convert_from_reference
< (convert_to_reference (type, value, CONV_C_CAST,
< LOOKUP_COMPLAIN, NULL_TREE)));
< else
< {
< tree ovalue;
---
> if (TREE_CODE (type) == VOID_TYPE)
> {
> value = require_complete_type_in_void (value);
> if (value != error_mark_node)
> value = build1 (CONVERT_EXPR, void_type_node, value);
> }
> else if (TREE_CODE (type) == REFERENCE_TYPE)
> value = (convert_from_reference
> (convert_to_reference (type, value, CONV_C_CAST,
> LOOKUP_COMPLAIN, NULL_TREE)));
> else
> {
> tree ovalue;
5774,5775c5868,5869
< if (TREE_READONLY_DECL_P (value))
< value = decl_constant_value (value);
---
> if (TREE_READONLY_DECL_P (value))
> value = decl_constant_value (value);
5777,5778c5871,5872
< ovalue = value;
< value = convert_force (type, value, CONV_C_CAST);
---
> ovalue = value;
> value = convert_force (type, value, CONV_C_CAST);
5780,5785c5874,5878
< /* Ignore any integer overflow caused by the cast. */
< if (TREE_CODE (value) == INTEGER_CST)
< {
< TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
< TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
< }
---
> /* Ignore any integer overflow caused by the cast. */
> if (TREE_CODE (value) == INTEGER_CST)
> {
> TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
> TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
5911a6005,6007
> if (lhs == error_mark_node)
> return lhs;
>
5958c6054
< newrhs = build_binary_op (modifycode, lhs, rhs, 1);
---
> newrhs = build_binary_op (modifycode, lhs, rhs);
6025c6121,6124
< && (TREE_READONLY (lhs) || TYPE_READONLY (lhstype)
---
> && (TREE_READONLY (lhs) || CP_TYPE_CONST_P (lhstype)
> /* Functions are not modifiable, even though they are
> lvalues. */
> || TREE_CODE (TREE_TYPE (lhs)) == FUNCTION_TYPE
6030c6129
< && TYPE_READONLY (TREE_TYPE (lhstype)))))
---
> && CP_TYPE_CONST_P (TREE_TYPE (lhstype)))))
6066,6073d6164
< /* The TREE_TYPE of RHS may be TYPE_UNKNOWN. This can happen
< when the type of RHS is not yet known, i.e. its type
< is inherited from LHS. */
< rhs = require_instantiated_type (lhstype, newrhs, error_mark_node);
< if (rhs == error_mark_node)
< return error_mark_node;
< newrhs = rhs;
<
6114c6205
< if (! comptypes (lhstype, TREE_TYPE (rhs), 0))
---
> if (!same_or_base_type_p (lhstype, TREE_TYPE (rhs)))
6274,6282d6364
< /* Return 0 if EXP is not a valid lvalue in this language
< even though `lvalue_or_else' would accept it. */
<
< int
< language_lvalue_valid (exp)
< tree exp ATTRIBUTE_UNUSED;
< {
< return 1;
< }
6286c6368
< TO type. If FORCE is true, then allow reverse conversions as well. */
---
> TO type. If FORCE is true, then allow reverse conversions as well.
6287a6370,6374
> Note that the naming of FROM and TO is kind of backwards; the return
> value is what we add to a TO in order to get a FROM. They are named
> this way because we call this function to find out how to convert from
> a pointer to member of FROM to a pointer to member of TO. */
>
6334c6421
< delta, 1);
---
> delta);
6353c6440
< static tree
---
> tree
6442,6447c6529,6530
< tree idx = integer_zero_node;
< tree delta = integer_zero_node;
< tree delta2 = integer_zero_node;
< tree vfield_offset;
< tree npfn = NULL_TREE;
<
---
> tree fn;
>
6450a6534,6537
> tree idx = integer_zero_node;
> tree delta = integer_zero_node;
> tree delta2 = integer_zero_node;
> tree npfn = NULL_TREE;
6461c6548
< && comp_target_types (type, pfn_type, 0) != 1)
---
> && comp_target_types (type, pfn_type, 1) != 1)
6464,6466c6551,6559
< ndelta = cp_convert (ptrdiff_type_node, build_component_ref (pfn, delta_identifier, NULL_TREE, 0));
< ndelta2 = cp_convert (ptrdiff_type_node, DELTA2_FROM_PTRMEMFUNC (pfn));
< idx = build_component_ref (pfn, index_identifier, NULL_TREE, 0);
---
> if (TREE_CODE (pfn) == PTRMEM_CST)
> {
> /* We could just build the resulting CONSTRUCTOR now, but we
> don't, relying on the general machinery below, together
> with constant-folding, to do the right thing. We don't
> want to return a PTRMEM_CST here, even though we could,
> because a pointer-to-member constant ceases to be a
> constant (from the point of view of the language) when it
> is cast to another type. */
6467a6561,6578
> expand_ptrmemfunc_cst (pfn, &ndelta, &idx, &npfn, &ndelta2);
> if (npfn)
> /* This constant points to a non-virtual function.
> NDELTA2 will be NULL, but it's value doesn't really
> matter since we won't use it anyhow. */
> ndelta2 = integer_zero_node;
> }
> else
> {
> ndelta = cp_convert (ptrdiff_type_node,
> build_component_ref (pfn,
> delta_identifier,
> NULL_TREE, 0));
> ndelta2 = cp_convert (ptrdiff_type_node,
> DELTA2_FROM_PTRMEMFUNC (pfn));
> idx = build_component_ref (pfn, index_identifier, NULL_TREE, 0);
> }
>
6471,6473c6582,6583
<
< delta = build_binary_op (PLUS_EXPR, ndelta, n, 1);
< delta2 = build_binary_op (PLUS_EXPR, ndelta2, n, 1);
---
> delta = build_binary_op (PLUS_EXPR, ndelta, n);
> delta2 = build_binary_op (PLUS_EXPR, ndelta2, n);
6475a6586
> /* If it's a virtual function, this is what we want. */
6483,6484c6594,6597
< e3 = build_ptrmemfunc1 (TYPE_GET_PTRMEMFUNC_TYPE (type), delta, idx, npfn,
< NULL_TREE);
---
> /* But if it's a non-virtual function, or NULL, we use this
> instead. */
> e3 = build_ptrmemfunc1 (TYPE_GET_PTRMEMFUNC_TYPE (type), delta,
> idx, npfn, NULL_TREE);
6497,6499c6610
< if (TREE_CODE (pfn) == TREE_LIST
< || (TREE_CODE (pfn) == ADDR_EXPR
< && TREE_CODE (TREE_OPERAND (pfn, 0)) == TREE_LIST))
---
> if (type_unknown_p (pfn))
6502,6504c6613,6616
< if (!force
< && comp_target_types (type, TREE_TYPE (pfn), 0) != 1)
< cp_error ("conversion to `%T' from `%T'", type, TREE_TYPE (pfn));
---
> fn = TREE_OPERAND (pfn, 0);
> my_friendly_assert (TREE_CODE (fn) == FUNCTION_DECL, 0);
> return make_ptrmem_cst (build_ptrmemfunc_type (type), fn);
> }
6506,6510c6618,6619
< /* Allow pointer to member conversions here. */
< delta = get_delta_difference (TYPE_METHOD_BASETYPE (TREE_TYPE (TREE_TYPE (pfn))),
< TYPE_METHOD_BASETYPE (TREE_TYPE (type)),
< force);
< delta2 = build_binary_op (PLUS_EXPR, delta2, delta, 1);
---
> /* Return the DELTA, IDX, PFN, and DELTA2 values for the PTRMEM_CST
> given by CST. */
6512,6513c6621,6631
< if (TREE_CODE (TREE_OPERAND (pfn, 0)) != FUNCTION_DECL)
< warning ("assuming pointer to member function is non-virtual");
---
> void
> expand_ptrmemfunc_cst (cst, delta, idx, pfn, delta2)
> tree cst;
> tree *delta;
> tree *idx;
> tree *pfn;
> tree *delta2;
> {
> tree type = TREE_TYPE (cst);
> tree fn = PTRMEM_CST_MEMBER (cst);
> tree ptr_class, fn_class;
6515,6523c6633
< if (TREE_CODE (TREE_OPERAND (pfn, 0)) == FUNCTION_DECL
< && DECL_VINDEX (TREE_OPERAND (pfn, 0)))
< {
< /* Find the offset to the vfield pointer in the object. */
< vfield_offset = get_binfo (DECL_CONTEXT (TREE_OPERAND (pfn, 0)),
< DECL_CLASS_CONTEXT (TREE_OPERAND (pfn, 0)),
< 0);
< vfield_offset = get_vfield_offset (vfield_offset);
< delta2 = size_binop (PLUS_EXPR, vfield_offset, delta2);
---
> my_friendly_assert (TREE_CODE (fn) == FUNCTION_DECL, 0);
6525,6528c6635,6648
< /* Map everything down one to make room for the null pointer to member. */
< idx = size_binop (PLUS_EXPR,
< DECL_VINDEX (TREE_OPERAND (pfn, 0)),
< integer_one_node);
---
> /* The class that the function belongs to. */
> fn_class = DECL_CLASS_CONTEXT (fn);
>
> /* The class that we're creating a pointer to member of. */
> ptr_class = TYPE_PTRMEMFUNC_OBJECT_TYPE (type);
>
> /* First, calculate the adjustment to the function's class. */
> *delta = get_delta_difference (fn_class, ptr_class, /*force=*/0);
>
> if (!DECL_VIRTUAL_P (fn))
> {
> *idx = size_binop (MINUS_EXPR, integer_zero_node, integer_one_node);
> *pfn = convert (TYPE_PTRMEMFUNC_FN_TYPE (type), build_addr_func (fn));
> *delta2 = NULL_TREE;
6532c6652,6657
< idx = size_binop (MINUS_EXPR, integer_zero_node, integer_one_node);
---
> /* If we're dealing with a virtual function, we have to adjust 'this'
> again, to point to the base which provides the vtable entry for
> fn; the call will do the opposite adjustment. */
> tree orig_class = DECL_VIRTUAL_CONTEXT (fn);
> tree binfo = binfo_or_else (orig_class, fn_class);
> *delta = size_binop (PLUS_EXPR, *delta, BINFO_OFFSET (binfo));
6534,6542c6659,6665
< if (type == TREE_TYPE (pfn))
< {
< npfn = pfn;
< }
< else
< {
< npfn = build1 (NOP_EXPR, type, pfn);
< TREE_CONSTANT (npfn) = TREE_CONSTANT (pfn);
< }
---
> /* Map everything down one to make room for the null PMF. */
> *idx = size_binop (PLUS_EXPR, DECL_VINDEX (fn), integer_one_node);
> *pfn = NULL_TREE;
>
> /* Offset from an object of PTR_CLASS to the vptr for ORIG_CLASS. */
> *delta2 = size_binop (PLUS_EXPR, *delta,
> get_vfield_offset (TYPE_BINFO (orig_class)));
6543a6667
> }
6545c6669,6692
< return build_ptrmemfunc1 (TYPE_GET_PTRMEMFUNC_TYPE (type), delta, idx, npfn, delta2);
---
> /* Return an expression for DELTA2 from the pointer-to-member function
> given by T. */
>
> tree
> delta2_from_ptrmemfunc (t)
> tree t;
> {
> if (TREE_CODE (t) == PTRMEM_CST)
> {
> tree delta;
> tree idx;
> tree pfn;
> tree delta2;
>
> expand_ptrmemfunc_cst (t, &delta, &idx, &pfn, &delta2);
> if (delta2)
> return delta2;
> }
>
> return (build_component_ref
> (build_component_ref (t,
> pfn_or_delta2_identifier, NULL_TREE,
> 0),
> delta2_identifier, NULL_TREE, 0));
6547a6695,6720
> /* Return an expression for PFN from the pointer-to-member function
> given by T. */
>
> tree
> pfn_from_ptrmemfunc (t)
> tree t;
> {
> if (TREE_CODE (t) == PTRMEM_CST)
> {
> tree delta;
> tree idx;
> tree pfn;
> tree delta2;
>
> expand_ptrmemfunc_cst (t, &delta, &idx, &pfn, &delta2);
> if (pfn)
> return pfn;
> }
>
> return (build_component_ref
> (build_component_ref (t,
> pfn_or_delta2_identifier, NULL_TREE,
> 0),
> pfn_identifier, NULL_TREE, 0));
> }
>
6564c6737
< char *errtype;
---
> const char *errtype;
6570c6743
< register enum tree_code coder = TREE_CODE (TREE_TYPE (rhs));
---
> register enum tree_code coder;
6572,6577d6744
< if (coder == UNKNOWN_TYPE)
< rhs = instantiate_type (type, rhs, 1);
<
< if (coder == ERROR_MARK)
< return error_mark_node;
<
6579,6582c6746
< {
< type = TREE_TYPE (type);
< codel = TREE_CODE (type);
< }
---
> my_friendly_abort (990505);
6583a6748,6750
> if (TREE_CODE (rhs) == OFFSET_REF)
> rhs = resolve_offset_ref (rhs);
>
6588c6755
< if (rhs == error_mark_node)
---
> if (rhs == error_mark_node || TREE_TYPE (rhs) == error_mark_node)
6590d6756
<
6594,6602d6759
< if (TREE_CODE (TREE_TYPE (rhs)) == OFFSET_TYPE)
< {
< rhs = resolve_offset_ref (rhs);
< if (rhs == error_mark_node)
< return error_mark_node;
< rhstype = TREE_TYPE (rhs);
< coder = TREE_CODE (rhstype);
< }
<
6604,6605c6761
< || TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE
< || TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE)
---
> || is_overloaded_fn (rhs))
6609a6766,6771
> /* If rhs is some sort of overloaded function, ocp_convert will either
> do the right thing or complain; we don't need to check anything else.
> So just hand off. */
> if (type_unknown_p (rhs))
> return ocp_convert (type, rhs, CONV_IMPLICIT, LOOKUP_NORMAL);
>
6612a6775,6778
> /* Issue warnings about peculiar, but legal, uses of NULL. */
> if (ARITHMETIC_TYPE_P (type) && rhs == null_node)
> cp_warning ("converting NULL to non-pointer type");
>
6619c6785
< if (comptypes (type, rhstype, 1))
---
> if (same_type_p (type, rhstype))
6711c6877
< if (! TYPE_READONLY (ttl) && TYPE_READONLY (ttr))
---
> if (!at_least_as_qualified_p (ttl, ttr))
6714c6880
< cp_pedwarn ("passing `%T' as argument %P of `%D' discards const",
---
> cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
6717c6883
< cp_pedwarn ("%s to `%T' from `%T' discards const",
---
> cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
6720,6728d6885
< if (! TYPE_VOLATILE (ttl) && TYPE_VOLATILE (ttr))
< {
< if (fndecl)
< cp_pedwarn ("passing `%T' as argument %P of `%D' discards volatile",
< rhstype, parmnum, fndecl);
< else
< cp_pedwarn ("%s to `%T' from `%T' discards volatile",
< errtype, type, rhstype);
< }
6772c6929
< sorry ("%s between pointer to members converting across virtual baseclasses", errtype);
---
> error ("%s between pointer to members converting across virtual baseclasses", errtype);
6775c6932
< else if (! TYPE_READONLY (ttl) && TYPE_READONLY (ttr))
---
> else if (!at_least_as_qualified_p (ttl, ttr))
6777,6778c6934,6937
< if (fndecl)
< cp_pedwarn ("passing `%T' as argument %P of `%D' discards const",
---
> if (string_conv_p (type, rhs, 1))
> /* converting from string constant to char *, OK. */;
> else if (fndecl)
> cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
6781c6940
< cp_pedwarn ("%s to `%T' from `%T' discards const",
---
> cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
6784,6792d6942
< else if (! TYPE_VOLATILE (ttl) && TYPE_VOLATILE (ttr))
< {
< if (fndecl)
< cp_pedwarn ("passing `%T' as argument %P of `%D' discards volatile",
< rhstype, parmnum, fndecl);
< else
< cp_pedwarn ("%s to `%T' from `%T' discards volatile",
< errtype, type, rhstype);
< }
6807c6957,6958
< int add_quals = 0, const_parity = 0, volatile_parity = 0;
---
> int add_quals = 0;
> int drops_quals = 0;
6816,6817c6967
< const_parity |= (TYPE_READONLY (ttl) < TYPE_READONLY (ttr));
< volatile_parity |= (TYPE_VOLATILE (ttl) < TYPE_VOLATILE (ttr));
---
> drops_quals |= !at_least_as_qualified_p (ttl, ttr);
6820,6821c6970
< && (TYPE_READONLY (ttl) > TYPE_READONLY (ttr)
< || TYPE_VOLATILE (ttl) > TYPE_VOLATILE (ttr)))
---
> && !at_least_as_qualified_p (ttr, ttl))
6849c6998
< if (const_parity)
---
> if (drops_quals)
6852c7001
< cp_pedwarn ("passing `%T' as argument %P of `%D' discards const",
---
> cp_pedwarn ("passing `%T' as argument %P of `%D' discards qualifiers",
6855c7004
< cp_pedwarn ("%s to `%T' from `%T' discards const",
---
> cp_pedwarn ("%s to `%T' from `%T' discards qualifiers",
6858,6866d7006
< if (volatile_parity)
< {
< if (fndecl)
< cp_pedwarn ("passing `%T' as argument %P of `%D' discards volatile",
< rhstype, parmnum, fndecl);
< else
< cp_pedwarn ("%s to `%T' from `%T' discards volatile",
< errtype, type, rhstype);
< }
6890c7030
< if (! comptypes (ttl, ttr, 0))
---
> if (!same_or_base_type_p (ttl, ttr))
6908c7048,7050
< else if (codel == POINTER_TYPE && coder == INTEGER_TYPE)
---
> else if (codel == POINTER_TYPE
> && (coder == INTEGER_TYPE
> || coder == BOOLEAN_TYPE))
6997,6998c7139,7140
< /* Convert RHS to be of type TYPE. If EXP is non-zero,
< it is the target of the initialization.
---
> /* Convert RHS to be of type TYPE.
> If EXP is non-zero, it is the target of the initialization.
7017c7159
< char *errtype;
---
> const char *errtype;
7036c7178
< if (TREE_CODE (TREE_TYPE (rhs)) == OFFSET_TYPE)
---
> if (TREE_CODE (rhs) == OFFSET_REF)
7050c7192,7194
< || TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE
---
> || (TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE
> && (TREE_CODE (type) != REFERENCE_TYPE
> || TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE))
7057,7063d7200
< if (coder == UNKNOWN_TYPE)
< {
< rhs = instantiate_type (type, rhs, 1);
< rhstype = TREE_TYPE (rhs);
< coder = TREE_CODE (rhstype);
< }
<
7090,7094c7227,7228
< rhs = require_complete_type (rhs);
< if (rhs == error_mark_node)
< return error_mark_node;
<
< if (exp != 0) exp = require_complete_type (exp);
---
> if (exp != 0)
> exp = require_complete_type (exp);
7111a7246,7252
> /* Issue warnings about peculiar, but legal, uses of NULL. We
> do this *before* the call to decl_constant_value so as to
> avoid duplicate warnings on code like `const int I = NULL;
> f(I);'. */
> if (ARITHMETIC_TYPE_P (type) && rhs == null_node)
> cp_warning ("converting NULL to non-pointer type");
>
7113a7255
>
7165c7307
< if (TYPE_READONLY (type)
---
> if (CP_TYPE_CONST_P (type)
7221a7364,7370
> /* Only operator new(...) throw(), can return NULL [expr.new/13]. */
> if ((DECL_NAME (current_function_decl) == ansi_opname[(int) NEW_EXPR]
> || DECL_NAME (current_function_decl) == ansi_opname[(int) VEC_NEW_EXPR])
> && !TYPE_NOTHROW_P (TREE_TYPE (current_function_decl))
> && null_ptr_cst_p (retval))
> cp_warning ("operator new should throw an exception, not return NULL");
>
7286c7435
< else if (TREE_TYPE (retval) == void_type_node)
---
> else if (TREE_CODE (TREE_TYPE (retval)) == VOID_TYPE)
7354,7356c7503,7505
< && ! TREE_STATIC (whats_returned)
< && IDENTIFIER_LOCAL_VALUE (DECL_NAME (whats_returned))
< && !TREE_PUBLIC (whats_returned))
---
> && DECL_FUNCTION_SCOPE_P (whats_returned)
> && !(TREE_STATIC (whats_returned)
> || TREE_PUBLIC (whats_returned)))
7366,7368c7515,7517
< && IDENTIFIER_LOCAL_VALUE (DECL_NAME (whats_returned))
< && !TREE_STATIC (whats_returned)
< && !TREE_PUBLIC (whats_returned))
---
> && DECL_FUNCTION_SCOPE_P (whats_returned)
> && !(TREE_STATIC (whats_returned)
> || TREE_PUBLIC (whats_returned)))
7406,7407c7555
< tree type;
< register enum tree_code code;
---
> tree type, idx;
7409,7416c7557
< /* Convert from references, etc. */
< exp = default_conversion (exp);
< type = TREE_TYPE (exp);
< code = TREE_CODE (type);
<
< if (IS_AGGR_TYPE_CODE (code))
< exp = build_type_conversion (CONVERT_EXPR, integer_type_node, exp, 1);
<
---
> exp = build_expr_type_conversion (WANT_INT | WANT_ENUM, exp, 1);
7421a7563,7566
> if (exp == error_mark_node)
> return error_mark_node;
>
> exp = default_conversion (exp);
7423c7568,7574
< code = TREE_CODE (type);
---
> idx = get_unwidened (exp, 0);
> /* We can't strip a conversion from a signed type to an unsigned,
> because if we did, int_fits_type_p would do the wrong thing
> when checking case values for being in range,
> and it's too hard to do the right thing. */
> if (TREE_UNSIGNED (TREE_TYPE (exp)) == TREE_UNSIGNED (TREE_TYPE (idx)))
> exp = idx;
7425,7445d7575
< if (code != INTEGER_TYPE && code != ENUMERAL_TYPE && code != ERROR_MARK)
< {
< error ("switch quantity not an integer");
< exp = error_mark_node;
< }
< else
< {
< tree idx;
<
< exp = default_conversion (exp);
< type = TREE_TYPE (exp);
< idx = get_unwidened (exp, 0);
< /* We can't strip a conversion from a signed type to an unsigned,
< because if we did, int_fits_type_p would do the wrong thing
< when checking case values for being in range,
< and it's too hard to do the right thing. */
< if (TREE_UNSIGNED (TREE_TYPE (exp))
< == TREE_UNSIGNED (TREE_TYPE (idx)))
< exp = idx;
< }
<
7474,7475c7604,7605
< && comptypes (TYPE_OFFSET_BASETYPE (from),
< TYPE_OFFSET_BASETYPE (to), 1))
---
> && same_type_p (TYPE_OFFSET_BASETYPE (from),
> TYPE_OFFSET_BASETYPE (to)))
7482,7483c7612
< if (TYPE_READONLY (from) > TYPE_READONLY (to)
< || TYPE_VOLATILE (from) > TYPE_VOLATILE (to))
---
> if (!at_least_as_qualified_p (to, from))
7486,7487c7615
< if (TYPE_READONLY (to) > TYPE_READONLY (from)
< || TYPE_VOLATILE (to) > TYPE_VOLATILE (from))
---
> if (!at_least_as_qualified_p (from, to))
7501c7629
< comptypes (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from), 1)
---
> same_type_p (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from))
7531c7659,7660
< TYPE_OFFSET_BASETYPE (from), -1))
---
> TYPE_OFFSET_BASETYPE (from),
> COMPARE_BASE | COMPARE_RELAXED))
7536c7665,7666
< (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from), -1);
---
> (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from),
> COMPARE_BASE | COMPARE_RELAXED);
7552,7553c7682,7683
< && comptypes (TYPE_OFFSET_BASETYPE (from),
< TYPE_OFFSET_BASETYPE (to), 1))
---
> && same_type_p (TYPE_OFFSET_BASETYPE (from),
> TYPE_OFFSET_BASETYPE (to)))
7557c7687,7688
< return comptypes (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from), 1);
---
> return same_type_p (TYPE_MAIN_VARIANT (to),
> TYPE_MAIN_VARIANT (from));
7576,7578d7706
< if (TREE_CODE (to) != TREE_CODE (from))
< return 1;
<
7581c7709,7710
< if (TREE_CODE (to) != FUNCTION_TYPE && TREE_CODE (to) != METHOD_TYPE)
---
> if (TREE_CODE (from) != FUNCTION_TYPE && TREE_CODE (from) != METHOD_TYPE
> && TREE_CODE (to) != FUNCTION_TYPE && TREE_CODE (to) != METHOD_TYPE)
7583,7584c7712
< if (TYPE_READONLY (from) > TYPE_READONLY (to)
< || TYPE_VOLATILE (from) > TYPE_VOLATILE (to))
---
> if (!at_least_as_qualified_p (to, from))
7588,7589c7716
< && (TYPE_READONLY (to) > TYPE_READONLY (from)
< || TYPE_VOLATILE (to) > TYPE_READONLY (from)))
---
> && !at_least_as_qualified_p (from, to))
7594c7721,7722
< if (TREE_CODE (to) != POINTER_TYPE)
---
> if (TREE_CODE (from) != POINTER_TYPE
> || TREE_CODE (to) != POINTER_TYPE)
7597a7726,7749
>
> /* Returns the type-qualifier set corresponding to TYPE. */
>
> int
> cp_type_quals (type)
> tree type;
> {
> while (TREE_CODE (type) == ARRAY_TYPE)
> type = TREE_TYPE (type);
>
> return TYPE_QUALS (type);
> }
>
> /* Returns non-zero if the TYPE contains a mutable member */
>
> int
> cp_has_mutable_p (type)
> tree type;
> {
> while (TREE_CODE (type) == ARRAY_TYPE)
> type = TREE_TYPE (type);
>
> return CLASS_TYPE_P (type) && CLASSTYPE_HAS_MUTABLE (type);
> }