forked from Imagelibrary/binutils-gdb
gdb
PR c++/9680: * c-exp.y (REINTERPRET_CAST, DYNAMIC_CAST, STATIC_CAST) (CONST_CAST): New tokens. (exp): Add new productions. (ident_tokens): Add const_cast, dynamic_cast, static_cast, and reinterpret_cast. (is_cast_operator): New function. (yylex): Handle cast operators specially. * eval.c (evaluate_subexp_standard) <UNOP_DYNAMIC_CAST, UNOP_REINTERPRET_CAST>: New cases. * expprint.c (print_subexp_standard): Likewise. (op_name_standard): Likewise. (dump_subexp_body_standard): Likewise. * parse.c (operator_length_standard): Likewise. * expression.h (enum exp_opcode): New constants UNOP_DYNAMIC_CAST, UNOP_REINTERPRET_CAST. * gdbtypes.c (class_types_same_p): New function. (is_ancestor): Use it. (is_public_ancestor): New function. (is_unique_ancestor_worker): Likewise. (is_unique_ancestor): Likewise. * gdbtypes.h (class_types_same_p, is_public_ancestor) (is_unique_ancestor): Declare. * valops.c (value_reinterpret_cast): New function. (dynamic_cast_check_1): Likewise. (dynamic_cast_check_2): Likewise. (value_dynamic_cast): Likewise. * value.h (value_reinterpret_cast, value_dynamic_cast): Declare. gdb/testsuite PR c++/9680: * gdb.cp/casts.cc: Add new classes and variables. * gdb.cp/casts.exp: Test new operators.
This commit is contained in:
@@ -410,6 +410,18 @@ print_subexp_standard (struct expression *exp, int *pos,
|
||||
fputs_filtered (")", stream);
|
||||
return;
|
||||
|
||||
case UNOP_DYNAMIC_CAST:
|
||||
case UNOP_REINTERPRET_CAST:
|
||||
fputs_filtered (opcode == UNOP_DYNAMIC_CAST ? "dynamic_cast"
|
||||
: "reinterpret_cast", stream);
|
||||
fputs_filtered ("<", stream);
|
||||
(*pos) += 2;
|
||||
type_print (exp->elts[pc + 1].type, "", stream, 0);
|
||||
fputs_filtered ("> (", stream);
|
||||
print_subexp (exp, pos, stream, PREC_PREFIX);
|
||||
fputs_filtered (")", stream);
|
||||
return;
|
||||
|
||||
case UNOP_MEMVAL:
|
||||
(*pos) += 2;
|
||||
if ((int) prec > (int) PREC_PREFIX)
|
||||
@@ -730,6 +742,10 @@ op_name_standard (enum exp_opcode opcode)
|
||||
return "OP_ARRAY";
|
||||
case UNOP_CAST:
|
||||
return "UNOP_CAST";
|
||||
case UNOP_DYNAMIC_CAST:
|
||||
return "UNOP_DYNAMIC_CAST";
|
||||
case UNOP_REINTERPRET_CAST:
|
||||
return "UNOP_REINTERPRET_CAST";
|
||||
case UNOP_MEMVAL:
|
||||
return "UNOP_MEMVAL";
|
||||
case UNOP_MEMVAL_TLS:
|
||||
@@ -1036,6 +1052,8 @@ dump_subexp_body_standard (struct expression *exp,
|
||||
break;
|
||||
case UNOP_MEMVAL:
|
||||
case UNOP_CAST:
|
||||
case UNOP_DYNAMIC_CAST:
|
||||
case UNOP_REINTERPRET_CAST:
|
||||
fprintf_filtered (stream, "Type @");
|
||||
gdb_print_host_address (exp->elts[elt].type, stream);
|
||||
fprintf_filtered (stream, " (");
|
||||
|
||||
Reference in New Issue
Block a user