This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Patch for incorrect handling of references to pointers [pr1147]
- From: Daniel Jacobowitz <drow at false dot org>
- To: Paul Pluzhnikov <ppluzhnikov at google dot com>
- Cc: gdb-patches at sourceware dot org, Doug Evans <dje at google dot com>
- Date: Thu, 5 Jun 2008 16:37:48 -0400
- Subject: Re: [RFA] Patch for incorrect handling of references to pointers [pr1147]
- References: <8ac60eac0805081418md64f7bcha08664e9554e5750@mail.gmail.com>
On Thu, May 08, 2008 at 02:18:53PM -0700, Paul Pluzhnikov wrote:
> Greetings,
>
> Attached patch fixes incorrect handling of "this" when reference
> to pointer is used:
> http://sourceware.org/cgi-bin/gnatsweb.pl?cmd=view&database=gdb&pr=1147
> and adds a test case for it.
Since there's a PR, please mention it in the changelog and commit
message; it'll show up in gnats automatically. Assuming we eventually
switch to bugzilla, the same thing will work there. For instance:
2008-05-08 Paul Pluzhnikov <ppluzhnikov@google.com>
PR gdb/1147
* valopts.c (find_overload_match): Handle references
to pointers.
> --- gdb/testsuite/gdb.cp/call-c.exp.orig 2008-05-08 14:01:57.000000000 -0700
> +++ gdb/testsuite/gdb.cp/call-c.exp 2008-05-08 13:54:14.497857000 -0700
> @@ -44,3 +44,6 @@ gdb_load ${binfile}
> runto_main
>
> gdb_test "print foo(1)" "\\\$$decimal = 1"
> +send_gdb "next\nnext\nnext\n"
> +gdb_expect -re "$gdb_prompt $"
> +gdb_test "print rf->func()" "\\\$$decimal = 1"
This is an unsafe use of send_gdb, because the gdb_expect might match
only the first of three expected prompts depending when there is a
pause in the output. In general, relying on multiple nexts makes the
test case hard to modify; can you set a breakpoint and use
gdb_get_line_number to find the line to break on?
> --- gdb/valops.c.orig 2008-05-08 14:01:57.000000000 -0700
> +++ gdb/valops.c 2008-05-08 13:57:14.320875000 -0700
> @@ -1919,7 +1919,8 @@ find_overload_match (struct type **arg_t
> if (objp)
> {
> if (TYPE_CODE (value_type (temp)) != TYPE_CODE_PTR
> - && TYPE_CODE (value_type (*objp)) == TYPE_CODE_PTR)
> + && (TYPE_CODE (value_type (*objp)) == TYPE_CODE_PTR
> + || (TYPE_CODE (value_type (*objp)) == TYPE_CODE_REF)))
One more set of parens on the last line than you need.
Sorry about the delay.
--
Daniel Jacobowitz
CodeSourcery