From a0949cc9e8167e48a7c37db96fe47a15f9e2450c Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 9 Mar 2018 12:13:55 +0000 Subject: [PATCH] [PR c++/84733] ICE in check-local-shadow https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00425.html PR c++/84733 * name-lookup.c (do_pushdecl_with_scope): Only clear current_function_decl when pushing a non-class (i.e. namespace) scope. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258383 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/name-lookup.c | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3c1e4c76a06..eeaf71d445e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-03-09 Nathan Sidwell + + PR c++/84733 + * name-lookup.c (do_pushdecl_with_scope): Only clear + current_function_decl when pushing a non-class (i.e. namespace) + scope. + 2018-03-08 Jason Merrill Jakub Jelinek diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 2773cf4d878..80a92ab0ac4 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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_binding_level *level, bool is_friend) } 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; } -- 2.11.4.GIT