aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>2006-01-04 14:46:17 +0000
committerFred Fish <fnf@specifix.com>2006-01-04 14:46:17 +0000
commitf4d85314470c1e74a91349ef869931eb9ce77c05 (patch)
tree2b16fc459f3183b10f7410fc714297227dbf6590 /gdb/testsuite/gdb.base
parent80911fe19f988336c8007920ebca92f68d5ff498 (diff)
downloadgdb-f4d85314470c1e74a91349ef869931eb9ce77c05.zip
gdb-f4d85314470c1e74a91349ef869931eb9ce77c05.tar.gz
gdb-f4d85314470c1e74a91349ef869931eb9ce77c05.tar.bz2
Reviewed and approved by Jim Blandy
2006-01-04 Fred Fish <fnf@specifix.com> * gdb.base/ptype.c (foo): Add typedef. (intfoo): Add function. * gdb.base/ptype1.c: New file. * gdb.base/ptype.exp: Handle compilation and linking with two source files. Test that proper type for "foo" is found based on source context rather than first match found in symtabs.
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/ptype.c9
-rw-r--r--gdb/testsuite/gdb.base/ptype.exp24
-rw-r--r--gdb/testsuite/gdb.base/ptype1.c6
3 files changed, 37 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.base/ptype.c b/gdb/testsuite/gdb.base/ptype.c
index 397a714..b847139 100644
--- a/gdb/testsuite/gdb.base/ptype.c
+++ b/gdb/testsuite/gdb.base/ptype.c
@@ -259,6 +259,15 @@ func_type v_func_type;
/***********/
+typedef int foo;
+
+foo intfoo (afoo)
+{
+ return (afoo * 2);
+}
+
+/***********/
+
int main ()
{
/* Ensure that malloc is a pointer type; avoid use of "void" and any include files. */
diff --git a/gdb/testsuite/gdb.base/ptype.exp b/gdb/testsuite/gdb.base/ptype.exp
index 6580b43..851d6b7 100644
--- a/gdb/testsuite/gdb.base/ptype.exp
+++ b/gdb/testsuite/gdb.base/ptype.exp
@@ -31,9 +31,17 @@ set prms_id 0
set bug_id 0
set testfile "ptype"
-set srcfile ${testfile}.c
+set srcfile0 ${testfile}.c
+set srcfile1 ${testfile}1.c
set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile0}" "${binfile}0.o" object {debug}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
@@ -574,6 +582,18 @@ ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \
ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \
"int (*(*(*)())())()"
+# Test printing type of typedefs in different scopes, with same name
+# but different type.
+
+gdb_test "list intfoo" ""
+gdb_test "ptype foo" "type = int" "ptype foo typedef after first list of intfoo"
+gdb_test "list charfoo" ""
+gdb_test "ptype foo" "type = char" "ptype foo typedef after first list of charfoo"
+gdb_test "list intfoo" ""
+gdb_test "ptype foo" "type = int" "ptype foo typedef after second list of intfoo"
+gdb_test "list charfoo" ""
+gdb_test "ptype foo" "type = char" "ptype foo typedef after second list of charfoo"
+
# Test printing type of string constants and array constants, but
# requires a running process. These call malloc, and can take a long
# time to execute over a slow serial link, so increase the timeout.
diff --git a/gdb/testsuite/gdb.base/ptype1.c b/gdb/testsuite/gdb.base/ptype1.c
new file mode 100644
index 0000000..2587150
--- /dev/null
+++ b/gdb/testsuite/gdb.base/ptype1.c
@@ -0,0 +1,6 @@
+typedef char foo;
+
+foo charfoo (afoo)
+{
+ return (afoo * 2);
+}