[PR c++/84733] ICE in check-local-shadow
authorNathan Sidwell <nathan@acm.org>
Fri, 9 Mar 2018 12:13:55 +0000 (12:13 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 9 Mar 2018 12:13:55 +0000 (12:13 +0000)
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.

From-SVN: r258383

gcc/cp/ChangeLog
gcc/cp/name-lookup.c

index 3c1e4c76a067064c618228a289eb69806eea5898..eeaf71d445e5a677f0ea6259d529a72504461efd 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2018-03-08  Jason Merrill  <jason@redhat.com>
            Jakub Jelinek  <jakub@redhat.com>
 
index 2773cf4d878b26aacd6f7ce0175b36b8e19757b2..80a92ab0ac4874109eaaf0c02b6ae386d669c776 100644 (file)
@@ -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;
 }