2018-03-09 Nathan Sidwell <nathan@acm.org>
PR c++/84733
* name-lookup.c (do_pushdecl_with_scope): Only clear
current_function_decl when pushing a non-class (i.e. namespace)
scope.
===================================================================
@@ -3965,9 +3965,7 @@ static tree
do_pushdecl_with_scope (tree x, cp_binding_level *level, bool is_friend)
{
cp_binding_level *b;
- tree function_decl = current_function_decl;
- current_function_decl = NULL_TREE;
if (level->kind == sk_class)
{
b = class_binding_level;
@@ -3977,12 +3975,15 @@ do_pushdecl_with_scope (tree x, cp_bindi
}
else
{
+ tree function_decl = current_function_decl;
+ if (level->kind == sk_namespace)
+ current_function_decl = NULL_TREE;
b = current_binding_level;
current_binding_level = level;
x = pushdecl (x, is_friend);
current_binding_level = b;
+ current_function_decl = function_decl;
}
- current_function_decl = function_decl;
return x;
}