* gdb.c++/local.exp: Don't expect Local to be in scope in main;
authorJim Blandy <jimb@codesourcery.com>
Wed, 5 Feb 2003 05:48:46 +0000 (05:48 +0000)
committerJim Blandy <jimb@codesourcery.com>
Wed, 5 Feb 2003 05:48:46 +0000 (05:48 +0000)
it's local to foobar.  Check for it there, and check that it's not
present in main.
* gdb.c++/local.cc (marker2): New function.
(foobar): Call marker1.
(main): Call marker2 instead of marker1.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.c++/local.cc
gdb/testsuite/gdb.c++/local.exp

index 10137e4..2f4bbbb 100644 (file)
@@ -1,3 +1,12 @@
+2003-02-05  Jim Blandy  <jimb@redhat.com>
+
+       * gdb.c++/local.exp: Don't expect Local to be in scope in main;
+       it's local to foobar.  Check for it there, and check that it's not
+       present in main.
+       * gdb.c++/local.cc (marker2): New function.
+       (foobar): Call marker1.
+       (main): Call marker2 instead of marker1.
+
 2003-02-04  Andrew Cagney  <ac131313@redhat.com>
 
        * gdb.disasm/mn10200.exp: Obsolete file.
index 5bfc44a..85fd6e1 100644 (file)
@@ -4,6 +4,9 @@ void marker1 (void)
 { 
 }
 
+void marker2 (void)
+{
+}
   
 int foobar (int x)
 {
@@ -20,6 +23,8 @@ int foobar (int x)
   static Local l1;
   char  c;
 
+  marker1 ();
+
   l.loc1 = 23;
 
   c = l.loc_foo('x');
@@ -56,6 +61,6 @@ int main()
 
    il.ilc = 'b';
    il.ip = &c;
-   marker1();
+   marker2();
  }
 }
index 971567d..5a375c1 100644 (file)
@@ -67,7 +67,7 @@ if ![runto 'marker1'] then {
     continue
 }
 
-gdb_test "up" ".*main.*" "up from marker1"
+gdb_test "up" ".*foobar.*" "up from marker1"
 
 # Local classes in g++ get names like "main.1::InnerLocal", just like local
 # static variables.  Some targets use "___" instead of ".".
@@ -102,8 +102,7 @@ send_gdb "ptype Local\n"
 gdb_expect {
   -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" }
   -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
-    # setup_kfail "gdb/483"
-    fail "ptype Local (gdb/483)"
+    kfail "gdb/483" "ptype Local"
   }
   -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*Local & operator *=\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((void|)\\);\[\r\n\t \]*char loc_foo\\(char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" }
   -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\)\r\n\}.*$gdb_prompt $" { xpass "ptype Local (old aCC)" }
@@ -111,6 +110,36 @@ gdb_expect {
   timeout             { fail "(timeout) ptype Local" }
 }
 
+gdb_test "break marker2"
+gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker2.*" \
+    "continuing to marker2"
+
+gdb_test "up" ".*main.*" "up from marker2"
+
+# Make sure that `Local' isn't in scope here; it's local to foobar.
+# setup_kfail "gdb/825"
+send_gdb "ptype Local\n"
+set eol "\[\t \]*\[\r\n\]+\[\t \]*"
+gdb_expect {
+    -re "No symbol \"Local\" in current context.*${gdb_prompt} $" {
+        pass "Local out of scope"
+    }
+    -re "ptype Local${eol}type = class Local {${eol}  public:${eol}    int loc1;${eol}${eol}    Local & operator=\\(Local const&\\);${eol}    Local\\(Local const&\\);${eol}    Local\\(\\);${eol}    char loc_foo\\(char\\);${eol}}${eol}${gdb_prompt} " {
+        # GCC emits STABS debugging information in a way that doesn't
+        # properly preserve the scoping of local classes.  I think
+        # we'd need to start using Sun's extensions to stabs to get
+        # this right.
+        kfail gdb/825 "Local out of scope"
+    }
+    -re ".*${gdb_prompt} $" {
+        fail "Local out of scope"
+    }
+    timeout {
+        fail "Local out of scope (timeout)"
+    }
+}
+        
+
 # DTS CLLbs14316 and CLLbs17058
 # coulter - I added a clause for HP's aCC compiler.  We print out the type
 #   as xx instead of const unsigned char, but we still have an expected failure