mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-28 12:24:04 +08:00

In this commit: commit 7022349d5c86bae74b49225515f42d2e221bd368 Date: Mon Sep 4 20:21:13 2017 +0100 Stop assuming no-debug-info functions return int A new if case was added to call_function_by_hand_dummy to decide if a function should be considered prototyped or not. Previously the code was structured like this: if (COND_1) ACTION_1 else if (COND_2) ACTION_2 else ACTION_3 With the new block the code now looks like this: if (COND_1) ACTION_1 if (NEW_COND) NEW_ACTION else if (COND_2) ACTION_2 else ACTION_3 Notice the new block was added as and 'if' not 'else if'. I'm running into a case where GDB executes ACTION_1 and then ACTION_2. Prior to the above commit GDB would only have executed ACTION_1. The actions in the code in question are trying to figure out if a function should be considered prototyped or not. When a function is not prototyped some arguments will be coerced, e.g. floats to doubles. The COND_1 / ACTION_1 are a very broad, any member function should be considered prototyped, however, after the above patch GDB is now executing the later ACTION_2 which checks to see if the function's type has the 'prototyped' flag set - this is not the case for the member functions I'm testing, and so GDB treats the function as unprototyped and casts the float argument to a double. I believe that adding the new check as 'if' rather than 'else if' was a mistake, and so in this commit I add in the missing 'else'. gdb/ChangeLog: * infcall.c (call_function_by_hand_dummy): Add missing 'else' when setting prototyped flag. gdb/testsuite/ChangeLog: * gdb.cp/method-call-in-c.cc (struct foo_type): Add static member function static_method. (global_var): New global. (main): Use new static_method to ensure it is compiled in. * gdb.cp/method-call-in-c.exp: Test calls to static member function.
62 lines
1.3 KiB
C++
62 lines
1.3 KiB
C++
/* This testcase is part of GDB, the GNU debugger.
|
|
|
|
Copyright 2021 Free Software Foundation, Inc.
|
|
|
|
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
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
struct baz_type
|
|
{
|
|
int a = 0;
|
|
int b = 1;
|
|
int c = 2;
|
|
};
|
|
|
|
struct foo_type
|
|
{
|
|
int func (baz_type b, float f)
|
|
{
|
|
return var++;
|
|
}
|
|
|
|
foo_type &operator+= (const baz_type &rhs)
|
|
{
|
|
var += (rhs.a + rhs.b + rhs.c);
|
|
return *this;
|
|
}
|
|
|
|
static int static_method (float f, baz_type b)
|
|
{
|
|
return b.a + b.b + b.c + (int) f;
|
|
}
|
|
|
|
int var = 120;
|
|
};
|
|
|
|
volatile int global_var;
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
baz_type b = {};
|
|
float f = 1.0;
|
|
|
|
foo_type foo;
|
|
|
|
foo += b;
|
|
|
|
global_var = foo.static_method (f, b);
|
|
|
|
return foo.func (b, f); /* Break here. */
|
|
}
|