static tree
original_type (tree t)
{
+ int quals = cp_type_quals (t);
while (t != error_mark_node
&& TYPE_NAME (t) != NULL_TREE)
{
break;
t = x;
}
- return t;
+ return cp_build_qualified_type (t, quals);
}
/* T1 and T2 are arithmetic or enumeration types. Return the type
default:;
}
- return cp_build_type_attribute_variant (t1, attributes);
+
+ if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes))
+ return t1;
+ else if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes))
+ return t2;
+ else
+ return cp_build_type_attribute_variant (t1, attributes);
}
/* Return the common type of two types.
/* This warning is not very useful, as it complains about printf. */
if (warn)
- warning (OPT_Wwrite_strings, "deprecated conversion from string constant to %qT'", totype);
+ warning (OPT_Wwrite_strings,
+ "deprecated conversion from string constant to %qT",
+ totype);
return 1;
}
tree member_scope;
tree result = NULL_TREE;
- if (object == error_mark_node || member == error_mark_node)
+ if (error_operand_p (object) || error_operand_p (member))
return error_mark_node;
gcc_assert (DECL_P (member) || BASELINK_P (member));
switch (code)
{
- case PLUS_EXPR:
- /* Handle the pointer + int case. */
- if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
- return cp_pointer_int_sum (PLUS_EXPR, op0, op1);
- else if (code1 == POINTER_TYPE && code0 == INTEGER_TYPE)
- return cp_pointer_int_sum (PLUS_EXPR, op1, op0);
- else
- common = 1;
- break;
-
case MINUS_EXPR:
/* Subtraction of two similar pointers.
We must subtract them as integers, then divide by object size. */
&& same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (type0),
TREE_TYPE (type1)))
return pointer_diff (op0, op1, common_type (type0, type1));
- /* Handle pointer minus int. Just like pointer plus int. */
- else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
- return cp_pointer_int_sum (MINUS_EXPR, op0, op1);
- else
- common = 1;
+ /* In all other cases except pointer - int, the usual arithmetic
+ rules aply. */
+ else if (!(code0 == POINTER_TYPE && code1 == INTEGER_TYPE))
+ {
+ common = 1;
+ break;
+ }
+ /* The pointer - int case is just like pointer + int; fall
+ through. */
+ case PLUS_EXPR:
+ if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE)
+ && (code0 == INTEGER_TYPE || code1 == INTEGER_TYPE))
+ {
+ tree ptr_operand;
+ tree int_operand;
+ ptr_operand = ((code0 == POINTER_TYPE) ? op0 : op1);
+ int_operand = ((code0 == INTEGER_TYPE) ? op0 : op1);
+ if (processing_template_decl)
+ {
+ result_type = TREE_TYPE (ptr_operand);
+ break;
+ }
+ return cp_pointer_int_sum (code,
+ ptr_operand,
+ int_operand);
+ }
+ common = 1;
break;
case MULT_EXPR:
else if (!(arg = build_expr_type_conversion (WANT_INT | WANT_ENUM,
arg, true)))
errstring = "wrong type argument to bit-complement";
- else if (!noconvert)
+ else if (!noconvert && CP_INTEGRAL_TYPE_P (TREE_TYPE (arg)))
arg = perform_integral_promotions (arg);
break;
pedwarn ("ISO C++ forbids taking the address of a cast to a non-lvalue expression");
break;
+ case BASELINK:
+ arg = BASELINK_FUNCTIONS (arg);
+ /* Fall through. */
+
case OVERLOAD:
arg = OVL_CURRENT (arg);
break;
/* Allow array assignment in compiler-generated code. */
if (! DECL_ARTIFICIAL (current_function_decl))
- pedwarn ("ISO C++ forbids assignment of arrays");
+ {
+ /* This routine is used for both initialization and assignment.
+ Make sure the diagnostic message differentiates the context. */
+ if (modifycode == INIT_EXPR)
+ error ("array used as initializer");
+ else
+ error ("invalid array assignment");
+ return error_mark_node;
+ }
from_array = TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE
? 1 + (modifycode != INIT_EXPR): 0;
}
}
+ while (TREE_CODE (whats_returned) == COMPONENT_REF
+ || TREE_CODE (whats_returned) == ARRAY_REF)
+ whats_returned = TREE_OPERAND (whats_returned, 0);
+
if (DECL_P (whats_returned)
&& DECL_NAME (whats_returned)
&& DECL_FUNCTION_SCOPE_P (whats_returned)