diff options
author | Sami Wagiaalla <swagiaal@redhat.com> | 2010-05-07 14:46:28 +0000 |
---|---|---|
committer | Sami Wagiaalla <swagiaal@redhat.com> | 2010-05-07 14:46:28 +0000 |
commit | 7322dca9c16dfce7e9019240ac21037f2a4d6cb7 (patch) | |
tree | 15ef1ee23eb0d09d802c4f8fc1424b430d2a76f8 /gdb/eval.c | |
parent | 3f1f688424574eaba15256ec436b564a8e2e8c20 (diff) | |
download | gdb-7322dca9c16dfce7e9019240ac21037f2a4d6cb7.zip gdb-7322dca9c16dfce7e9019240ac21037f2a4d6cb7.tar.gz gdb-7322dca9c16dfce7e9019240ac21037f2a4d6cb7.tar.bz2 |
Add ADL support
2010-05-07 Sami Wagiaalla <swagiaal@redhat.com>
PR C++/7943:
* valops.c (find_overload_match): Handle fsym == NULL case.
Add int no_adl argument.
(find_oload_champ_namespace_loop): Call make_symbol_overload_list_adl
when appropriate.
Add int no_adl argument.
(find_oload_champ_namespace): Add int no_adl argument.
* parse.c (operator_length_standard): Return length for OP_ADL_FUNC
expression.
* expprint.c (op_name_standard): Added string for OP_ADL_FUNC case.
* eval.c (evaluate_subexp_standard): Added OP_ADL_FUNC case.
Evaluate arguments and use them to perform ADL lookup.
Pass no_adl argument to find_overload_match.
Disable adl lookup when evaluating a fully qualified OP_FUNCALL.
* cp-support.h: Added prototype for
make_symbol_overload_list_namespace.
* cp-support.c (make_symbol_overload_list_namespace): New function.
(make_symbol_overload_list_adl_namespace): New function.
(make_symbol_overload_list_adl): New function.
(make_symbol_overload_list_using): Moved code to add function to
overload set to make_symbol_overload_list_namespace.
* c-exp.y: create UNKNOWN_CPP_NAME token.
Add parse rule for ADL functions.
(classify_name): Recognize an UNKNOWN_CPP_NAME.
2010-05-07 Sami Wagiaalla <swagiaal@redhat.com>
* gdb.cp/koenig.exp: New test.
* gdb.cp/koenig.cc: New test program.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r-- | gdb/eval.c | 47 |
1 files changed, 45 insertions, 2 deletions
@@ -731,6 +731,7 @@ evaluate_subexp_standard (struct type *expect_type, 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) @@ -1452,6 +1453,17 @@ evaluate_subexp_standard (struct type *expect_type, 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 */ @@ -1482,6 +1494,32 @@ evaluate_subexp_standard (struct type *expect_type, /* 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)) @@ -1513,7 +1551,7 @@ evaluate_subexp_standard (struct type *expect_type, (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) { @@ -1565,6 +1603,11 @@ evaluate_subexp_standard (struct type *expect_type, { /* 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; @@ -1577,7 +1620,7 @@ evaluate_subexp_standard (struct type *expect_type, (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) { |