aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorDavid Carlton <carlton@bactrian.org>2003-05-20 03:56:29 +0000
committerDavid Carlton <carlton@bactrian.org>2003-05-20 03:56:29 +0000
commit1fcb515536dbda348515162ccdb82cb102928798 (patch)
tree025f43d1ac23661032fceed14c7ed49de57c2f09 /gdb/testsuite
parent916f5d137a4e411facadf4ade434a6eba27b6ea5 (diff)
downloadgdb-1fcb515536dbda348515162ccdb82cb102928798.zip
gdb-1fcb515536dbda348515162ccdb82cb102928798.tar.gz
gdb-1fcb515536dbda348515162ccdb82cb102928798.tar.bz2
2003-05-19 David Carlton <carlton@bactrian.org>
Partial fix for PR c++/827. * cp-support.h: Include symtab.h. Declare cp_lookup_symbol_nonlocal, cp_lookup_symbol_namespace. * cp-namespace.c: Update contributors. (cp_lookup_symbol_nonlocal): New. (lookup_namespace_scope, cp_lookup_symbol_namespace) (lookup_symbol_file): Ditto. * c-lang.c (cplus_language_defn): Use cp_lookup_symbol_nonlocal. * block.h: Declare block_scope, block_using, block_global_block. * block.c (block_scope): New. (block_using, block_global_block): Ditto. * Makefile.in (cp_support_h): Depend on symtab_h. * config/djgpp/fnchange.lst: Add testsuite/gdb.c++/namespace1.cc. 2003-05-19 David Carlton <carlton@bactrian.org> * gdb.c++/namespace.exp: Add namespace scope and anonymous namespace tests. Bump copyright date. * gdb.c++/namespace.cc: Add anonymous namespace and namespace C. (main): Call C::D::marker2. * gdb.c++/namespace1.cc: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.c++/namespace.cc70
-rw-r--r--gdb/testsuite/gdb.c++/namespace.exp43
3 files changed, 111 insertions, 11 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 27eae48..a2fb2db 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2003-05-19 David Carlton <carlton@bactrian.org>
+
+ * gdb.c++/namespace.exp: Add namespace scope and anonymous
+ namespace tests.
+ Bump copyright date.
+ * gdb.c++/namespace.cc: Add anonymous namespace and namespace C.
+ (main): Call C::D::marker2.
+ * gdb.c++/namespace1.cc: New file.
+
2003-05-14 Jeff Johnston <jjohnstn@redhat.com>
Roland McGrath <roland@redhat.com>
diff --git a/gdb/testsuite/gdb.c++/namespace.cc b/gdb/testsuite/gdb.c++/namespace.cc
index 7667266..7b9a173 100644
--- a/gdb/testsuite/gdb.c++/namespace.cc
+++ b/gdb/testsuite/gdb.c++/namespace.cc
@@ -68,6 +68,70 @@ void marker1(void)
return;
}
+namespace
+{
+ int X = 9;
+
+ namespace G
+ {
+ int Xg = 10;
+ }
+}
+
+namespace C
+{
+ int c = 1;
+ int shadow = 12;
+
+ namespace
+ {
+ int cX = 6;
+
+ namespace F
+ {
+ int cXf = 7;
+ }
+ }
+
+ namespace C
+ {
+ int cc = 2;
+ }
+
+ namespace D
+ {
+ int cd = 3;
+ int shadow = 13;
+
+ namespace E
+ {
+ int cde = 5;
+ }
+
+ void marker2 (void)
+ {
+ // NOTE: carlton/2003-04-23: I'm listing the expressions that I
+ // plan to have GDB try to print out, just to make sure that the
+ // compiler and I agree which ones should be legal! It's easy
+ // to screw up when testing the boundaries of namespace stuff.
+ c;
+ //cc;
+ C::cc;
+ cd;
+ E::cde;
+ shadow;
+ cX;
+ F::cXf;
+ X;
+ G::Xg;
+ //cXOtherFile;
+ //XOtherFile;
+
+ return;
+ }
+
+ }
+}
int main ()
{
@@ -95,9 +159,5 @@ int main ()
marker1();
+ C::D::marker2 ();
}
-
-
-
-
-
diff --git a/gdb/testsuite/gdb.c++/namespace.exp b/gdb/testsuite/gdb.c++/namespace.exp
index 3e502c4..f4efaf6 100644
--- a/gdb/testsuite/gdb.c++/namespace.exp
+++ b/gdb/testsuite/gdb.c++/namespace.exp
@@ -1,4 +1,4 @@
-# Copyright 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 1997, 1998, 2000, 2001, 2002, 2003 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
@@ -39,20 +39,26 @@ if { [skip_cplus_tests] } { continue }
set testfile "namespace"
set srcfile ${testfile}.cc
+set objfile ${objdir}/${subdir}/${testfile}.o
+set srcfile1 ${testfile}1.cc
+set objfile1 ${objdir}/${subdir}/${testfile}1.o
set binfile ${objdir}/${subdir}/${testfile}
if [get_compiler_info ${binfile}] {
return -1;
}
-
-
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
- gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will a
-utomatically fail."
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug c++}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${objfile1}" object {debug c++}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+if { [gdb_compile "${objfile} ${objfile1}" "${binfile}" executable {debug c++}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
gdb_exit
gdb_start
@@ -186,3 +192,28 @@ gdb_expect {
timeout { fail "(timeout) break BBB::Class::xyzq" }
}
+# Test to see if the appropriate namespaces are in scope when trying
+# to print out stuff from within a function defined within a
+# namespace.
+
+if ![runto "C::D::marker2"] then {
+ perror "couldn't run to marker2"
+ continue
+}
+
+gdb_test "print c" "\\$\[0-9\].* = 1"
+gdb_test "print cc" "No symbol \"cc\" in current context."
+gdb_test "print 'C::cc'" "\\$\[0-9\].* = 2"
+gdb_test "print cd" "\\$\[0-9\].* = 3"
+gdb_test "print 'E::cde'" "\\$\[0-9\].* = 5"
+gdb_test "print shadow" "\\$\[0-9\].* = 13"
+gdb_test "print cOtherFile" "\\$\[0-9\].* = 316"
+
+# Some anonymous namespace tests.
+
+gdb_test "print cX" "\\$\[0-9\].* = 6"
+gdb_test "print 'F::cXf'" "\\$\[0-9\].* = 7"
+gdb_test "print X" "\\$\[0-9\].* = 9"
+gdb_test "print 'G::Xg'" "\\$\[0-9\].* = 10"
+gdb_test "print cXOtherFile" "No symbol \"cXOtherFile\" in current context."
+gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context."