View | Details | Raw Unified | Return to bug 43145
Collapse All | Expand All | Context: (Patch / File /
)

(-)a/gcc/cp/cp-tree.h (+1 lines)
 Lines 4640-4645   extern tree pushdecl_top_level_and_finish (tree, tree); Link Here 
4640
extern tree check_for_out_of_scope_variable	(tree);
4640
extern tree check_for_out_of_scope_variable	(tree);
4641
extern void print_other_binding_stack		(struct cp_binding_level *);
4641
extern void print_other_binding_stack		(struct cp_binding_level *);
4642
extern tree maybe_push_decl			(tree);
4642
extern tree maybe_push_decl			(tree);
4643
extern tree current_decl_namespace		(void);
4643
4644
4644
/* decl.c */
4645
/* decl.c */
4645
extern tree poplevel				(int, int, int);
4646
extern tree poplevel				(int, int, int);
(-)a/gcc/cp/decl.c (-2 / +2 lines)
 Lines 6755-6761   grokfndecl (tree ctype, Link Here 
6755
  if (in_namespace)
6755
  if (in_namespace)
6756
    set_decl_namespace (decl, in_namespace, friendp);
6756
    set_decl_namespace (decl, in_namespace, friendp);
6757
  else if (!ctype)
6757
  else if (!ctype)
6758
    DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
6758
    DECL_CONTEXT (decl) = FROB_CONTEXT (current_decl_namespace ());
6759
6759
6760
  /* `main' and builtins have implicit 'C' linkage.  */
6760
  /* `main' and builtins have implicit 'C' linkage.  */
6761
  if ((MAIN_NAME_P (declarator)
6761
  if ((MAIN_NAME_P (declarator)
 Lines 7015-7021   grokvardecl (tree type, Link Here 
7015
      /* An explicit "extern" specifier indicates a namespace-scope
7015
      /* An explicit "extern" specifier indicates a namespace-scope
7016
	 variable.  */
7016
	 variable.  */
7017
      if (declspecs->storage_class == sc_extern)
7017
      if (declspecs->storage_class == sc_extern)
7018
	scope = current_namespace;
7018
	scope = current_decl_namespace ();
7019
      else if (!at_function_scope_p ())
7019
      else if (!at_function_scope_p ())
7020
	scope = current_scope ();
7020
	scope = current_scope ();
7021
    }
7021
    }
(-)a/gcc/cp/name-lookup.c (-1 / +2 lines)
 Lines 3170-3176   set_decl_namespace (tree decl, tree scope, bool friendp) Link Here 
3170
3170
3171
/* Return the namespace where the current declaration is declared.  */
3171
/* Return the namespace where the current declaration is declared.  */
3172
3172
3173
static tree
3173
tree
3174
current_decl_namespace (void)
3174
current_decl_namespace (void)
3175
{
3175
{
3176
  tree result;
3176
  tree result;
 Lines 3342-3347   void Link Here 
3342
pop_nested_namespace (tree ns)
3342
pop_nested_namespace (tree ns)
3343
{
3343
{
3344
  timevar_push (TV_NAME_LOOKUP);
3344
  timevar_push (TV_NAME_LOOKUP);
3345
  gcc_assert (current_namespace == ns);
3345
  while (ns != global_namespace)
3346
  while (ns != global_namespace)
3346
    {
3347
    {
3347
      pop_namespace ();
3348
      pop_namespace ();
(-)a/gcc/testsuite/g++.dg/lookup/ns4.C (+20 lines)
Line 0    Link Here 
1
// { dg-do link }
2
3
namespace N {
4
  void f();
5
}
6
7
void N::f()
8
{
9
  extern int i;
10
  extern void g();
11
  i = 1;
12
  g();
13
}
14
15
namespace N {
16
  int i;
17
  void g() { }
18
}
19
20
int main() { }

Return to bug 43145