From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31382 invoked by alias); 2 Dec 2009 18:05:49 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 31077 invoked by uid 9561); 2 Dec 2009 18:05:47 -0000 Date: Wed, 02 Dec 2009 18:05:00 -0000 Message-ID: <20091202180547.31043.qmail@sourceware.org> From: swagiaal@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-keiths-expr-cumulative: Fix rh bz 541093 X-Git-Refname: refs/heads/archer-keiths-expr-cumulative X-Git-Reftype: branch X-Git-Oldrev: a81cfe86441450877621addb7866d1f10caefce5 X-Git-Newrev: f3e1558f5fe481a645f628a05197beb76c063b6a X-SW-Source: 2009-q4/txt/msg00094.txt.bz2 List-Id: The branch, archer-keiths-expr-cumulative has been updated via f3e1558f5fe481a645f628a05197beb76c063b6a (commit) from a81cfe86441450877621addb7866d1f10caefce5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit f3e1558f5fe481a645f628a05197beb76c063b6a Author: Sami Wagiaalla Date: Tue Dec 1 12:01:41 2009 -0500 Fix rh bz 541093 ----------------------------------------------------------------------- Summary of changes: gdb/cp-namespace.c | 73 +++++++++------ .../gdb.cp/namespace-stress-declarations.cc | 93 ++++++++++++++++++++ .../gdb.cp/namespace-stress-declarations.exp | 50 +++++++++++ 3 files changed, 187 insertions(+), 29 deletions(-) create mode 100644 gdb/testsuite/gdb.cp/namespace-stress-declarations.cc create mode 100644 gdb/testsuite/gdb.cp/namespace-stress-declarations.exp First 500 lines of diff: diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index af0ba28..db26a01 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -406,6 +406,16 @@ cp_lookup_symbol_in_namespace (const char *namespace, } } +/* Used for cleanups to reset the "searched" flag incase + of an error. */ + +static void +reset_directive_searched (void *data) +{ + struct using_direct *direct = data; + direct->searched = 0; +} + /* Search for NAME by applying all import statements belonging to BLOCK which are applicable in SCOPE. If DECLARATION_ONLY the search is restricted to using declarations. @@ -433,16 +443,17 @@ cp_lookup_symbol_in_namespace (const char *namespace, struct symbol * cp_lookup_symbol_imports (const char *scope, - const char *name, - const struct block *block, - const domain_enum domain, - int declaration_only, - int search_parents) + const char *name, + const struct block *block, + const domain_enum domain, + int declaration_only, + int search_parents) { struct using_direct *current; struct symbol *sym = NULL; int directive_match; int current_line; + struct cleanup *searched_cleanup; if(!declaration_only) /* First, try to find the symbol in the given namespace. */ @@ -478,6 +489,8 @@ cp_lookup_symbol_imports (const char *scope, !current->searched) { current->searched = 1; + searched_cleanup = make_cleanup (reset_directive_searched, current); + /* If there is an import of a single declaration, compare the imported declaration with the sought out name. If there is a match pass current->import_src as NAMESPACE to direct the search towards the @@ -486,23 +499,25 @@ cp_lookup_symbol_imports (const char *scope, { if (strcmp (name, current->declaration) == 0) { - sym = cp_lookup_symbol_in_namespace (current->import_src, - name, - block, - domain); + sym = cp_lookup_symbol_in_namespace (current->import_src, + name, + block, + domain); } + + current->searched = 0; + if (sym) + return sym; + + continue; } if (declaration_only) - { - current->searched = 0; - if (sym) - { - return sym; - } else { - continue; - } - } + { + current->searched = 0; + discard_cleanups (searched_cleanup); + continue; + } if (strcmp (name, current->alias) == 0) /* If the import is creating an alias and the alias matches the @@ -510,25 +525,25 @@ cp_lookup_symbol_imports (const char *scope, search towards the aliased namespace */ { sym = cp_lookup_symbol_in_namespace (scope, - current->import_src, - block, - domain); + current->import_src, + block, + domain); } else if (strcmp ("", current->alias) == 0){ /* If this import statement creates no alias, pass current->inner as NAMESPACE to direct the search towards the imported namespace. */ sym = cp_lookup_symbol_imports (current->import_src, - name, - block, - domain, - 0, - 0); + name, + block, + domain, + 0, + 0); } current->searched = 0; + discard_cleanups (searched_cleanup); + if (sym != NULL) - { - return sym; - } + return sym; } } diff --git a/gdb/testsuite/gdb.cp/namespace-stress-declarations.cc b/gdb/testsuite/gdb.cp/namespace-stress-declarations.cc new file mode 100644 index 0000000..173e49b --- /dev/null +++ b/gdb/testsuite/gdb.cp/namespace-stress-declarations.cc @@ -0,0 +1,93 @@ +int a; +int b; +int c; +int d; +int e; +int f; +int g; +int h; +int i; +int j; +int k; +int l; +int m; +int n; +int o; +int p; +int q; +int r; +int s; +int t; +int u; +int v; +int w; +int x; +int y; +int z; + +namespace A +{ + int xyz; + + using ::a; + using ::b; + using ::c; + using ::d; + using ::e; + using ::f; + using ::g; + using ::h; + using ::i; + using ::j; + using ::k; + using ::l; + using ::m; + using ::n; + using ::o; + using ::p; + using ::q; + using ::r; + using ::s; + using ::t; + using ::u; + using ::v; + using ::w; + using ::x; + using ::y; + using ::z; + +} + +using A::a; +using A::b; +using A::c; +using A::d; +using A::e; +using A::f; +using A::g; +using A::h; +using A::i; +using A::j; +using A::k; +using A::l; +using A::m; +using A::n; +using A::o; +using A::p; +using A::q; +using A::r; +using A::s; +using A::t; +using A::u; +using A::v; +using A::w; +using A::x; +using A::y; +using A::z; + +using namespace A; + +int main () +{ + return 0; +} \ No newline at end of file diff --git a/gdb/testsuite/gdb.cp/namespace-stress-declarations.exp b/gdb/testsuite/gdb.cp/namespace-stress-declarations.exp new file mode 100644 index 0000000..f22a14e --- /dev/null +++ b/gdb/testsuite/gdb.cp/namespace-stress-declarations.exp @@ -0,0 +1,50 @@ +# Copyright 2008 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 . + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +set testfile namespace-stress-declarations +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested "Couldn't compile test program" + return -1 +} + +if [get_compiler_info ${binfile}] { + return -1; +} + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +############################################ +# Test that the search can fail efficiently + +gdb_test "print fakex" "No symbol \"fakex\" in current context." hooks/post-receive -- Repository for Project Archer.