mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
dc3a371e83
I've been playing with a board file that forces every testcase to include a header file that does something like: #define main __gdb_testcase_main and then links an actual main() function that does some initialization and then jumps to __gdb_testcase_main. That runs into a number of testcases relying on main not having an explicit return statement, like e.g.,: gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/catch-follow-exec.c:27:1: warning: non-void function does not return a value [-Wreturn-type] gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/catch-signal.c:47:1: warning: non-void function does not return a value [-Wreturn-type] We don't get those warnings without my board because it is valid to not explicitly return from main. There's an implicit "return 0;". Since it doesn't hurt to be explicit, I've went ahead and added the explicit return statements. Also, a couple testcases either don't explicitly specify main's return type, or return void. Those are tweaked to explicitly return int. gdb/testsuite/ChangeLog: * gdb.base/catch-follow-exec.c (main): Add explicit return statement. * gdb.base/catch-signal.c (main): Likewise. * gdb.base/condbreak-call-false.c (main): Likewise. * gdb.base/consecutive.c (main): Add explicit return statement and return type. * gdb.base/cursal.c (main): Add explicit return statement. * gdb.base/cvexpr.c (main): Likewise. * gdb.base/display.c (main): Add explicit return statement and return type. * gdb.base/dprintf-detach.c (main): Add explicit return statement. * gdb.base/endianity.c (main): Likewise. * gdb.base/execd-prog.c (main): Likewise. * gdb.base/gdb1090.c (main): Likewise. * gdb.base/info_qt.c (main): Likewise. * gdb.base/lineinc.c (main): Likewise. * gdb.base/load-command.c (main): Likewise. * gdb.base/macscp1.c (main): Likewise. * gdb.base/pr10179-a.c (main): Likewise. * gdb.base/quit-live.c (main): Likewise. * gdb.base/scope0.c (main): Likewise. * gdb.base/settings.c (main): Likewise. * gdb.base/stack-checking.c (main): Return int. * gdb.base/varargs.c (main): Add explicit return statement. * gdb.cp/ambiguous.cc (main): Likewise. * gdb.cp/anon-struct.cc (main): Likewise. * gdb.cp/anon-union.cc (main): Likewise. * gdb.cp/bool.cc (main): Likewise. * gdb.cp/bs15503.cc (main): Likewise. * gdb.cp/cplusfuncs.cc (main): Likewise. * gdb.cp/cttiadd.cc (main): Likewise. * gdb.cp/extern-c.cc (main): Likewise. * gdb.cp/filename.cc (main): Likewise. * gdb.cp/formatted-ref.cc (main): Likewise. * gdb.cp/mb-ctor.cc (main): Likewise. * gdb.cp/member-ptr.cc (main): Likewise. * gdb.cp/minsym-fallback-main.cc (main): Likewise. * gdb.cp/overload-const.cc (main): Likewise. * gdb.cp/paren-type.cc (main): Likewise. * gdb.cp/parse-lang.cc (main): Likewise. * gdb.cp/pr-1023.cc (main): Likewise. * gdb.cp/psmang1.cc (main): Likewise. * gdb.cp/readnow-language.cc (main): Likewise. * gdb.cp/ref-params.cc (main): Likewise. * gdb.cp/rvalue-ref-params.cc (main): Likewise. * gdb.cp/virtbase2.cc (main): Likewise. * gdb.dwarf2/dw2-abs-hi-pc.c (main): Likewise. * gdb.dwarf2/dw2-namespaceless-anonymous.c (main): Likewise. * gdb.dwarf2/dw4-toplevel-types.cc (main): Likewise. * gdb.mi/mi-console.c (main): Likewise. * gdb.mi/mi-read-memory.c (main): Likewise. * gdb.modula2/multidim.c (main): Likewise. * gdb.opt/inline-small-func.c (main): Likewise. * gdb.python/py-rbreak.c (main): Likewise. * gdb.stabs/exclfwd1.c (main): Likewise. * gdb.trace/qtro.c (main): Likewise.
198 lines
7.8 KiB
C++
198 lines
7.8 KiB
C++
#include <stddef.h>
|
|
|
|
class foo {
|
|
public:
|
|
foo (int);
|
|
foo (int, const char *);
|
|
foo (foo&);
|
|
~foo ();
|
|
|
|
void operator * (foo&);
|
|
void operator % (foo&);
|
|
void operator - (foo&);
|
|
void operator >> (foo&);
|
|
void operator != (foo&);
|
|
void operator > (foo&);
|
|
void operator >= (foo&);
|
|
void operator | (foo&);
|
|
void operator && (foo&);
|
|
void operator ! (void);
|
|
void operator ++ (int);
|
|
void operator = (foo&);
|
|
void operator += (foo&);
|
|
void operator *= (foo&);
|
|
void operator %= (foo&);
|
|
void operator >>= (foo&);
|
|
void operator |= (foo&);
|
|
void operator , (foo&);
|
|
void operator / (foo&);
|
|
void operator + (foo&);
|
|
void operator << (foo&);
|
|
void operator == (foo&);
|
|
void operator < (foo&);
|
|
void operator <= (foo&);
|
|
void operator & (foo&);
|
|
void operator ^ (foo&);
|
|
void operator || (foo&);
|
|
void operator ~ (void);
|
|
void operator -- (int);
|
|
foo* operator -> (void);
|
|
void operator -= (foo&);
|
|
void operator /= (foo&);
|
|
void operator <<= (foo&);
|
|
void operator &= (foo&);
|
|
void operator ^= (foo&);
|
|
void operator ->* (foo&);
|
|
void operator [] (foo&);
|
|
void operator () (foo&);
|
|
void* operator new (size_t) throw ();
|
|
void* operator new[] (size_t) throw ();
|
|
void operator delete (void *);
|
|
void operator delete[] (void *);
|
|
/**/ operator int ();
|
|
/**/ operator char* ();
|
|
|
|
int foofunc (int); // forced to have int return type, which is required
|
|
int foofunc (int, signed char *); // forced to have int return type, which is required
|
|
int ifoo;
|
|
const char *ccpfoo;
|
|
};
|
|
|
|
int main () {
|
|
int z=3;
|
|
|
|
return 0;
|
|
}
|
|
|
|
foo::foo (int i) { ifoo = i;}
|
|
foo::foo (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; }
|
|
foo::foo (foo& afoo) { afoo.ifoo = 0; }
|
|
foo::~foo () {}
|
|
|
|
void foo::operator * (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator % (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator - (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator >> (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator != (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator > (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator >= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator | (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator && (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator ! (void) {}
|
|
void foo::operator ++ (int ival) { ival = 0; }
|
|
void foo::operator = (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator += (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator *= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator %= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator >>= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator |= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator , (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator / (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator + (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator << (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator == (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator < (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator <= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator & (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator ^ (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator || (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator ~ (void) {}
|
|
void foo::operator -- (int ival) { ival = 0; }
|
|
foo* foo::operator -> (void) {return this;}
|
|
void foo::operator -= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator /= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator <<= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator &= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator ^= (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator ->* (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator [] (foo& afoo) { afoo.ifoo = 0; }
|
|
void foo::operator () (foo& afoo) { afoo.ifoo = 0; }
|
|
void* foo::operator new (size_t ival) throw () { ival = 0; return 0; }
|
|
void* foo::operator new[] (size_t ival) throw () { ival = 0; return 0; }
|
|
void foo::operator delete (void *ptr) { ptr = 0; }
|
|
void foo::operator delete[] (void *ptr) { ptr = 0; }
|
|
/**/ foo::operator int () { return 0; }
|
|
/**/ foo::operator char* () { return 0; }
|
|
|
|
/* Some functions to test overloading by varying one argument type. */
|
|
|
|
void overload1arg (void) { }
|
|
void overload1arg (char arg) { arg = 0; }
|
|
void overload1arg (signed char arg) { arg = 0; }
|
|
void overload1arg (unsigned char arg) { arg = 0; }
|
|
void overload1arg (short arg) { arg = 0; }
|
|
void overload1arg (unsigned short arg) { arg = 0; }
|
|
void overload1arg (int arg) { arg = 0; }
|
|
void overload1arg (unsigned int arg) { arg = 0; }
|
|
void overload1arg (long arg) { arg = 0; }
|
|
void overload1arg (unsigned long arg) { arg = 0; }
|
|
void overload1arg (float arg) { arg = 0; }
|
|
void overload1arg (double arg) { arg = 0; }
|
|
|
|
/* Some functions to test overloading by varying argument count. */
|
|
|
|
void overloadargs (int a1) { a1 = 0; }
|
|
void overloadargs (int a1, int a2) { a1 = a2 = 0; }
|
|
void overloadargs (int a1, int a2, int a3) { a1 = a2 = a3 = 0; }
|
|
void overloadargs (int a1, int a2, int a3, int a4)
|
|
{ a1 = a2 = a3 = a4 = 0; }
|
|
void overloadargs (int a1, int a2, int a3, int a4, int a5)
|
|
{ a1 = a2 = a3 = a4 = a5 = 0; }
|
|
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6)
|
|
{ a1 = a2 = a3 = a4 = a5 = a6 = 0; }
|
|
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7)
|
|
{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0; }
|
|
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
|
|
int a8)
|
|
{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0; }
|
|
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
|
|
int a8, int a9)
|
|
{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0; }
|
|
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
|
|
int a8, int a9, int a10)
|
|
{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 =
|
|
a10 = 0; }
|
|
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
|
|
int a8, int a9, int a10, int a11)
|
|
{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 =
|
|
a10 = a11 == 0; }
|
|
|
|
/* Some hairy function definitions.
|
|
Use typedefs to help maintain sanity. */
|
|
|
|
typedef int (*PFPc_i)(char *);
|
|
typedef short (*PFPl_s)(long *);
|
|
typedef short (*PFPc_s)(char *);
|
|
typedef int (*PFl_i)(long);
|
|
typedef PFl_i (*PFPc_PFl_i)(char *);
|
|
typedef PFl_i (*PFPi_PFl_i)(int *);
|
|
typedef PFl_i (*PFPFPc_i_PFl_i)(PFPc_i);
|
|
typedef PFl_i (*PFs_PFl_i)(short);
|
|
typedef int (*PFPFPl_s_i)(PFPl_s);
|
|
typedef int (*PFPFPc_s_i)(PFPc_s);
|
|
|
|
PFs_PFl_i hairyfunc1 (int arg) { arg = 0; return 0; }
|
|
int hairyfunc2 (PFPc_i arg) { arg = 0; return 0; }
|
|
int hairyfunc3 (PFPFPl_s_i arg) { arg = 0; return 0; }
|
|
int hairyfunc4 (PFPFPc_s_i arg) { arg = 0; return 0; }
|
|
int hairyfunc5 (PFPc_PFl_i arg) { arg = 0; return 0; }
|
|
int hairyfunc6 (PFPi_PFl_i arg) { arg = 0; return 0; }
|
|
int hairyfunc7 (PFPFPc_i_PFl_i arg) { arg = 0; return 0; }
|
|
|
|
/* gdb has two demanglers (one for g++ 2.95, one for g++ 3).
|
|
These marker functions help me figure out which demangler is in use. */
|
|
|
|
char * dm_type_char_star (char * p) { return p; }
|
|
int dm_type_foo_ref (foo & foo) { return foo.ifoo; }
|
|
int * dm_type_int_star (int * p) { return p; }
|
|
long * dm_type_long_star (long * p) { return p; }
|
|
int dm_type_short (short i) { return i; }
|
|
int dm_type_long (long i) { return i; }
|
|
int dm_type_unsigned_int (unsigned int i) { return i; }
|
|
int dm_type_unsigned_short (unsigned short i) { return i; }
|
|
int dm_type_unsigned_long (unsigned long i) { return i; }
|
|
int dm_type_void (void) { return 0; }
|
|
void * dm_type_void_star (void * p) { return p; }
|
|
typedef int myint;
|
|
int dm_type_typedef (myint i) { return i; }
|