]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Reviewed and approved by Jim Blandy
authorFred Fish <fnf@specifix.com>
Wed, 4 Jan 2006 14:46:17 +0000 (14:46 +0000)
committerFred Fish <fnf@specifix.com>
Wed, 4 Jan 2006 14:46:17 +0000 (14:46 +0000)
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.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/ptype.c
gdb/testsuite/gdb.base/ptype.exp
gdb/testsuite/gdb.base/ptype1.c [new file with mode: 0644]

index 04de4c3e7633a29768c28e1981e530e7bb0eafa6..eb1a2f262a19a651a23eb91366ab4443255c15cd 100644 (file)
@@ -1,3 +1,12 @@
+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.
+
 2005-12-28  Mark Kettenis  <kettenis@gnu.org>
 
        * gdb.asm/asm-source.exp (hppa-*-openbsd*): New.
index 397a714692bf7f7253f161b96022e902674b540b..b8471399613f99b78cfbc12b521973b885beb079 100644 (file)
@@ -257,6 +257,15 @@ func_type v_func_type;
    will all xfail.  */
 
 
+/***********/
+
+typedef int foo;
+
+foo intfoo (afoo)
+{
+  return (afoo * 2);
+}
+
 /***********/
 
 int main ()
index 6580b43c4279583e3090864f48bc38532a7b2142..851d6b7b776262224d24b80297f20a8e36daec7e 100644 (file)
@@ -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 (file)
index 0000000..2587150
--- /dev/null
@@ -0,0 +1,6 @@
+typedef char foo;
+
+foo charfoo (afoo)
+{
+  return (afoo * 2);
+}