diff options
author | Daniel Jacobowitz <drow@false.org> | 2007-09-23 16:25:06 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2007-09-23 16:25:06 +0000 |
commit | 41f1b6975dce5616800a8ff1acb544019c7bc132 (patch) | |
tree | f3e49925507634d70cb6d6e1fbd9ce7c6b8ec313 /gdb/testsuite | |
parent | 3f213f78ed9182dbdeb3500dab729a6aad17dfd9 (diff) | |
download | gdb-41f1b6975dce5616800a8ff1acb544019c7bc132.zip gdb-41f1b6975dce5616800a8ff1acb544019c7bc132.tar.gz gdb-41f1b6975dce5616800a8ff1acb544019c7bc132.tar.bz2 |
* infcall.c (call_function_by_hand): Handle language-specific
pass and return by reference.
* cp-abi.c (cp_pass_by_reference): New.
* cp-abi.h (cp_pass_by_reference): Declare.
(struct cp_abi_ops): Add pass_by_reference.
* gnu-v3-abi.c (gnuv3_pass_by_reference): New.
(init_gnuv3_ops): Set pass_by_reference.
* language.c (language_pass_by_reference): New.
(default_pass_by_reference): New.
(unknown_language_defn, auto_language_defn, local_language_defn): Add
default_pass_by_reference.
* langauge.h (struct language_defn): Add la_pass_by_reference.
(language_pass_by_reference, default_pass_by_reference): Declare.
* ada-lang.c (ada_language_defn): Add default_pass_by_reference.
* c-lang.c (c_language_defn, asm_language_defn)
(minimal_language_defn): Likewise.
(cplus_language_defn): Add cp_pass_by_reference.
* f-lang.c (f_language_defn): Add default_pass_by_reference.
* jv-lang.c (java_language_defn): Likewise.
* m2-lang.c (m2_language_defn): Likewise.
* objc-lang.c (objc_language_defn): Likewise.
* p-lang.c (pascal_language_defn): Likewise.
* scm-lang.c (scm_language_defn): Likewise
* gdb.cp/pass-by-ref.cc, gdb.cp/pass-by-ref.exp: New files.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/pass-by-ref.cc | 79 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/pass-by-ref.exp | 41 |
3 files changed, 124 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 8b30f8c..ae563f5 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2007-09-23 Daniel Jacobowitz <dan@codesourcery.com> + + * gdb.cp/pass-by-ref.cc, gdb.cp/pass-by-ref.exp: New files. + 2007-09-23 Pedro Alves <pedro_alves@portugalmail.pt> * configure.ac: Do gdb.stabs tests by default on Cygwin and MinGW diff --git a/gdb/testsuite/gdb.cp/pass-by-ref.cc b/gdb/testsuite/gdb.cp/pass-by-ref.cc new file mode 100644 index 0000000..2a34b36 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pass-by-ref.cc @@ -0,0 +1,79 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2007 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/>. */ + +class Obj { +public: + Obj (); + Obj (const Obj &); + ~Obj (); + int var[2]; +}; + +int foo (Obj arg) +{ + return arg.var[0] + arg.var[1]; +} + +Obj::Obj () +{ + var[0] = 1; + var[1] = 2; +} + +Obj::Obj (const Obj &obj) +{ + var[0] = obj.var[0]; + var[1] = obj.var[1]; +} + +Obj::~Obj () +{ + +} + +struct Derived : public Obj +{ + int other; +}; + +int blap (Derived arg) +{ + return foo (arg); +} + +struct Container +{ + Obj obj; +}; + +int blip (Container arg) +{ + return foo (arg.obj); +} + +Obj global_obj; +Derived global_derived; +Container global_container; + +int +main () +{ + int bar = foo (global_obj); + blap (global_derived); + blip (global_container); + return bar; +} diff --git a/gdb/testsuite/gdb.cp/pass-by-ref.exp b/gdb/testsuite/gdb.cp/pass-by-ref.exp new file mode 100644 index 0000000..f218c82 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pass-by-ref.exp @@ -0,0 +1,41 @@ +# Copyright 2007 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/>. + +# Check that GDB can call C++ functions whose parameters have +# object type, but are passed by reference. + +if { [skip_cplus_tests] } { continue } + +set testfile "pass-by-ref" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ + executable {debug c++}] != "" } { + untested pass-by-ref.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + return -1 +} + +gdb_test "print foo (global_obj)" " = 3" "call function in obj" +gdb_test "print blap (global_derived)" " = 3" "call function in derived" +gdb_test "print blip (global_container)" " = 3" "call function in container" |