}
static int
-ptrmath_type_p (struct type *type)
+ptrmath_type_p (const struct language_defn *lang, struct type *type)
{
type = check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_REF)
return 1;
case TYPE_CODE_ARRAY:
- return current_language->c_style_arrays;
+ return lang->c_style_arrays;
default:
return 0;
struct type *type;
int nargs;
struct value **argvec;
- int upper, lower, retcode;
+ int upper, lower;
int code;
int ix;
long mem_offset;
return value_from_decfloat (exp->elts[pc + 1].type,
exp->elts[pc + 2].decfloatconst);
+ case OP_ADL_FUNC:
case OP_VAR_VALUE:
(*pos) += 3;
if (noside == EVAL_SKIP)
{
/* Unpack it locally so we can properly handle overload
resolution. */
- struct type *qual_type;
char *name;
int local_tem;
tem = 2;
}
}
+ else if (op == OP_ADL_FUNC)
+ {
+ /* Save the function position and move pos so that the arguments
+ can be evaluated. */
+ int func_name_len;
+ save_pos1 = *pos;
+ tem = 1;
+
+ func_name_len = longest_to_int (exp->elts[save_pos1 + 3].longconst);
+ (*pos) += 6 + BYTES_TO_EXP_ELEM (func_name_len + 1);
+ }
else
{
/* Non-method function call */
/* signal end of arglist */
argvec[tem] = 0;
+ if (op == OP_ADL_FUNC)
+ {
+ struct symbol *symp;
+ char *func_name;
+ int name_len;
+ int string_pc = save_pos1 + 3;
+
+ /* Extract the function name. */
+ name_len = longest_to_int (exp->elts[string_pc].longconst);
+ func_name = (char *) alloca (name_len + 1);
+ strcpy (func_name, &exp->elts[string_pc + 1].string);
+
+ /* Prepare list of argument types for overload resolution */
+ arg_types = (struct type **) alloca (nargs * (sizeof (struct type *)));
+ for (ix = 1; ix <= nargs; ix++)
+ arg_types[ix - 1] = value_type (argvec[ix]);
+
+ find_overload_match (arg_types, nargs, func_name,
+ 0 /* not method */ , 0 /* strict match */ ,
+ NULL, NULL /* pass NULL symbol since symbol is unknown */ ,
+ NULL, &symp, NULL, 0);
+
+ /* Now fix the expression being evaluated. */
+ exp->elts[save_pos1 + 2].symbol = symp;
+ argvec[0] = evaluate_subexp_with_coercion (exp, &save_pos1, noside);
+ }
if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR
|| (op == OP_SCOPE && function_name != NULL))
(void) find_overload_match (arg_types, nargs, tstr,
1 /* method */ , 0 /* strict match */ ,
&arg2 /* the object */ , NULL,
- &valp, NULL, &static_memfuncp);
+ &valp, NULL, &static_memfuncp, 0);
if (op == OP_SCOPE && !static_memfuncp)
{
{
/* Language is C++, do some overload resolution before evaluation */
struct symbol *symp;
+ int no_adl = 0;
+
+ /* If a scope has been specified disable ADL. */
+ if (op == OP_SCOPE)
+ no_adl = 1;
if (op == OP_VAR_VALUE)
function = exp->elts[save_pos1+2].symbol;
(void) find_overload_match (arg_types, nargs, NULL /* no need for name */ ,
0 /* not method */ , 0 /* strict match */ ,
NULL, function /* the function */ ,
- NULL, &symp, NULL);
+ NULL, &symp, NULL, no_adl);
if (op == OP_VAR_VALUE)
{
op = exp->elts[pc + 1].opcode;
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op, noside);
- else if (op == BINOP_ADD && ptrmath_type_p (value_type (arg1))
+ else if (op == BINOP_ADD && ptrmath_type_p (exp->language_defn,
+ value_type (arg1))
&& is_integral_type (value_type (arg2)))
arg2 = value_ptradd (arg1, value_as_long (arg2));
- else if (op == BINOP_SUB && ptrmath_type_p (value_type (arg1))
+ else if (op == BINOP_SUB && ptrmath_type_p (exp->language_defn,
+ value_type (arg1))
&& is_integral_type (value_type (arg2)))
arg2 = value_ptradd (arg1, - value_as_long (arg2));
else
goto nosideret;
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, op, OP_NULL, noside);
- else if (ptrmath_type_p (value_type (arg1))
+ else if (ptrmath_type_p (exp->language_defn, value_type (arg1))
&& is_integral_type (value_type (arg2)))
return value_ptradd (arg1, value_as_long (arg2));
- else if (ptrmath_type_p (value_type (arg2))
+ else if (ptrmath_type_p (exp->language_defn, value_type (arg2))
&& is_integral_type (value_type (arg1)))
return value_ptradd (arg2, value_as_long (arg1));
else
goto nosideret;
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, op, OP_NULL, noside);
- else if (ptrmath_type_p (value_type (arg1))
- && ptrmath_type_p (value_type (arg2)))
+ else if (ptrmath_type_p (exp->language_defn, value_type (arg1))
+ && ptrmath_type_p (exp->language_defn, value_type (arg2)))
{
/* FIXME -- should be ptrdiff_t */
type = builtin_type (exp->gdbarch)->builtin_long;
return value_from_longest (type, value_ptrdiff (arg1, arg2));
}
- else if (ptrmath_type_p (value_type (arg1))
+ else if (ptrmath_type_p (exp->language_defn, value_type (arg1))
&& is_integral_type (value_type (arg2)))
return value_ptradd (arg1, - value_as_long (arg2));
else
}
else
{
- if (ptrmath_type_p (value_type (arg1)))
+ if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
arg2 = value_ptradd (arg1, 1);
else
{
}
else
{
- if (ptrmath_type_p (value_type (arg1)))
+ if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
arg2 = value_ptradd (arg1, -1);
else
{
}
else
{
- if (ptrmath_type_p (value_type (arg1)))
+ if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
arg2 = value_ptradd (arg1, 1);
else
{
}
else
{
- if (ptrmath_type_p (value_type (arg1)))
+ if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
arg2 = value_ptradd (arg1, -1);
else
{
var = exp->elts[pc + 2].symbol;
type = check_typedef (SYMBOL_TYPE (var));
if (TYPE_CODE (type) == TYPE_CODE_ARRAY
- && CAST_IS_CONVERSION)
+ && CAST_IS_CONVERSION (exp->language_defn))
{
(*pos) += 4;
val = address_of_variable (var, exp->elts[pc + 1].block);