forked from Imagelibrary/binutils-gdb
gdb/
* eval.c (evaluate_subexp_for_address): Don't incorrectly discard calls to C++ operator*. gdb/testsuite/ * gdb.cp/userdef.cc, gdb.cp/userdef.exp: New tests for unary operator*.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2006-07-25 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
|
* eval.c (evaluate_subexp_for_address): Don't incorrectly discard
|
||||||
|
calls to C++ operator*.
|
||||||
|
|
||||||
2006-07-24 Roger Sayle <roger@eyesopen.com>
|
2006-07-24 Roger Sayle <roger@eyesopen.com>
|
||||||
Daniel Jacobowitz <dan@codesourcery.com>
|
Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
|
|||||||
24
gdb/eval.c
24
gdb/eval.c
@@ -2132,6 +2132,7 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
|
|||||||
enum exp_opcode op;
|
enum exp_opcode op;
|
||||||
int pc;
|
int pc;
|
||||||
struct symbol *var;
|
struct symbol *var;
|
||||||
|
struct value *x;
|
||||||
|
|
||||||
pc = (*pos);
|
pc = (*pos);
|
||||||
op = exp->elts[pc].opcode;
|
op = exp->elts[pc].opcode;
|
||||||
@@ -2140,7 +2141,24 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
|
|||||||
{
|
{
|
||||||
case UNOP_IND:
|
case UNOP_IND:
|
||||||
(*pos)++;
|
(*pos)++;
|
||||||
return evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
||||||
|
|
||||||
|
/* We can't optimize out "&*" if there's a user-defined operator*. */
|
||||||
|
if (unop_user_defined_p (op, x))
|
||||||
|
{
|
||||||
|
x = value_x_unop (x, op, noside);
|
||||||
|
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
||||||
|
{
|
||||||
|
if (VALUE_LVAL (x) == lval_memory)
|
||||||
|
return value_zero (lookup_pointer_type (value_type (x)),
|
||||||
|
not_lval);
|
||||||
|
else
|
||||||
|
error (_("Attempt to take address of non-lval"));
|
||||||
|
}
|
||||||
|
return value_addr (x);
|
||||||
|
}
|
||||||
|
|
||||||
|
return x;
|
||||||
|
|
||||||
case UNOP_MEMVAL:
|
case UNOP_MEMVAL:
|
||||||
(*pos) += 3;
|
(*pos) += 3;
|
||||||
@@ -2179,16 +2197,16 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
default_case:
|
default_case:
|
||||||
|
x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
||||||
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
||||||
{
|
{
|
||||||
struct value *x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
||||||
if (VALUE_LVAL (x) == lval_memory)
|
if (VALUE_LVAL (x) == lval_memory)
|
||||||
return value_zero (lookup_pointer_type (value_type (x)),
|
return value_zero (lookup_pointer_type (value_type (x)),
|
||||||
not_lval);
|
not_lval);
|
||||||
else
|
else
|
||||||
error (_("Attempt to take address of non-lval"));
|
error (_("Attempt to take address of non-lval"));
|
||||||
}
|
}
|
||||||
return value_addr (evaluate_subexp (NULL_TYPE, exp, pos, noside));
|
return value_addr (x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
2006-07-25 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
|
* gdb.cp/userdef.cc, gdb.cp/userdef.exp: New tests for unary
|
||||||
|
operator*.
|
||||||
|
|
||||||
2006-07-24 Daniel Jacobowitz <dan@codesourcery.com>
|
2006-07-24 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
* gdb.base/completion.exp: Update for change in "file" behavior.
|
* gdb.base/completion.exp: Update for change in "file" behavior.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* This test script is part of GDB, the GNU debugger.
|
/* This test script is part of GDB, the GNU debugger.
|
||||||
|
|
||||||
Copyright 1999, 2002, 2003, 2004, 2005
|
Copyright 1999, 2002, 2003, 2004, 2005, 2006
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
@@ -306,12 +306,31 @@ A2 A2::operator+()
|
|||||||
return A2 ();
|
return A2 ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Member
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int z;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Container
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Member m;
|
||||||
|
|
||||||
|
Member& operator* ();
|
||||||
|
};
|
||||||
|
|
||||||
|
Member& Container::operator* ()
|
||||||
|
{
|
||||||
|
return this->m;
|
||||||
|
}
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
A1 one(2,3);
|
A1 one(2,3);
|
||||||
A1 two(4,5);
|
A1 two(4,5);
|
||||||
A1 three(0,0);
|
A1 three(0,0);
|
||||||
|
Container c;
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
marker1(); // marker1-returns-here
|
marker1(); // marker1-returns-here
|
||||||
@@ -379,6 +398,8 @@ int main (void)
|
|||||||
++three;
|
++three;
|
||||||
cout << "preinc " << three;
|
cout << "preinc " << three;
|
||||||
|
|
||||||
|
(*c).z = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# Tests of overloaded operators resolution.
|
# Tests of overloaded operators resolution.
|
||||||
# Copyright 1998, 1999, 2002, 2004, 2005 Free Software Foundation, Inc.
|
# Copyright 1998, 1999, 2002, 2004, 2005, 2006
|
||||||
|
# Free Software Foundation, Inc.
|
||||||
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -143,5 +144,11 @@ gdb_test "print two = one" "\\\$\[0-9\]* = {x = 9, y = 10}"
|
|||||||
gdb_test "break A2::'operator+'" ".*Breakpoint $decimal at.*"
|
gdb_test "break A2::'operator+'" ".*Breakpoint $decimal at.*"
|
||||||
gdb_test "break A2::'operator +'" ".*Breakpoint $decimal at.*"
|
gdb_test "break A2::'operator +'" ".*Breakpoint $decimal at.*"
|
||||||
|
|
||||||
|
# Check that GDB handles operator* correctly.
|
||||||
|
gdb_test "print c" "\\\$\[0-9\]* = {m = {z = .*}}"
|
||||||
|
gdb_test "print *c" "\\\$\[0-9\]* = \\(Member &\\) @$hex: {z = .*}"
|
||||||
|
gdb_test "print &*c" "\\\$\[0-9\]* = \\(Member \\*\\) $hex"
|
||||||
|
gdb_test "ptype &*c" "type = struct Member {\[\r\n \]+int z;\[\r\n\]+} &\\*"
|
||||||
|
|
||||||
gdb_exit
|
gdb_exit
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user