name-lookup.c (current_decl_namespace): Non-static.

* name-lookup.c (current_decl_namespace): Non-static.
	(pop_nested_namespace): Sanity check.
	* cp-tree.h: Declare current_decl_namespace.
	* decl.c (grokvardecl): Use it instead of current_namespace.
	(grokfndecl): Likewise.
	* gnu/gcj/runtime/natSharedLibLoader.cc (findCore): Move
	declaration of _Jv_create_core out of the function.

From-SVN: r158074
This commit is contained in:
Jason Merrill 2010-04-07 11:55:02 -04:00 committed by Jason Merrill
parent feb3b88ad7
commit ae099258d3
8 changed files with 42 additions and 4 deletions

View File

@ -1,5 +1,11 @@
2010-04-07 Jason Merrill <jason@redhat.com>
* name-lookup.c (current_decl_namespace): Non-static.
(pop_nested_namespace): Sanity check.
* cp-tree.h: Declare current_decl_namespace.
* decl.c (grokvardecl): Use it instead of current_namespace.
(grokfndecl): Likewise.
PR c++/38392
* pt.c (tsubst_friend_function): Instatiate a friend that has already
been used.

View File

@ -4644,6 +4644,7 @@ extern tree pushdecl_top_level_and_finish (tree, tree);
extern tree check_for_out_of_scope_variable (tree);
extern void print_other_binding_stack (struct cp_binding_level *);
extern tree maybe_push_decl (tree);
extern tree current_decl_namespace (void);
/* decl.c */
extern tree poplevel (int, int, int);

View File

@ -6758,7 +6758,7 @@ grokfndecl (tree ctype,
if (in_namespace)
set_decl_namespace (decl, in_namespace, friendp);
else if (!ctype)
DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
DECL_CONTEXT (decl) = FROB_CONTEXT (current_decl_namespace ());
/* `main' and builtins have implicit 'C' linkage. */
if ((MAIN_NAME_P (declarator)
@ -7020,7 +7020,7 @@ grokvardecl (tree type,
/* An explicit "extern" specifier indicates a namespace-scope
variable. */
if (declspecs->storage_class == sc_extern)
scope = current_namespace;
scope = current_decl_namespace ();
else if (!at_function_scope_p ())
scope = current_scope ();
}

View File

@ -3170,7 +3170,7 @@ set_decl_namespace (tree decl, tree scope, bool friendp)
/* Return the namespace where the current declaration is declared. */
static tree
tree
current_decl_namespace (void)
{
tree result;
@ -3342,6 +3342,7 @@ void
pop_nested_namespace (tree ns)
{
timevar_push (TV_NAME_LOOKUP);
gcc_assert (current_namespace == ns);
while (ns != global_namespace)
{
pop_namespace ();

View File

@ -1,5 +1,7 @@
2010-04-07 Jason Merrill <jason@redhat.com>
* g++.dg/lookup/ns4.C: New.
PR c++/38392
* g++.dg/template/friend51.C: New test.

View File

@ -0,0 +1,20 @@
// { dg-do link }
namespace N {
void f();
}
void N::f()
{
extern int i;
extern void g();
i = 1;
g();
}
namespace N {
int i;
void g() { }
}
int main() { }

View File

@ -1,3 +1,8 @@
2010-04-07 Jason Merrill <jason@redhat.com>
* gnu/gcj/runtime/natSharedLibLoader.cc (findCore): Move
declaration of _Jv_create_core out of the function.
2010-04-02 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* Makefile.in: Regenerate.

View File

@ -119,11 +119,14 @@ gnu::gcj::runtime::SharedLibHelper::hasResource (jstring name)
#endif
}
#ifdef HAVE_DLOPEN
extern gnu::gcj::Core *_Jv_create_core (_Jv_core_chain *node, jstring name);
#endif
gnu::gcj::Core *
gnu::gcj::runtime::SharedLibHelper::findCore (jstring name)
{
#ifdef HAVE_DLOPEN
extern gnu::gcj::Core *_Jv_create_core (_Jv_core_chain *node, jstring name);
ensureInit();
return _Jv_create_core ((_Jv_core_chain *) core_chain, name);
#else