name-lookup.c (leave_scope): We only need to update class_binding_level when leaving...
authorRoger Sayle <roger@eyesopen.com>
Tue, 7 Dec 2004 14:41:12 +0000 (14:41 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Tue, 7 Dec 2004 14:41:12 +0000 (14:41 +0000)
* name-lookup.c (leave_scope): We only need to update
class_binding_level when leaving a class scope.

From-SVN: r91807

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

index 8569e1815cb377a13985dd6ae12e7b0563e7c419..dd41800eb078ee01263058c490bba1c44dca2c51 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-07  Roger Sayle  <roger@eyesopen.com>
+
+       * name-lookup.c (leave_scope): We only need to update
+       class_binding_level when leaving a class scope.
+
 2004-12-06  Ziemowit Laski  <zlaski@apple.com>
 
        * cp-tree.h (struct lang_type_class): Add 'objc_protocols' field.
index 6d5d00deb15b13351d518fb5d9eff77afb94a148..cfd3890cea730ec0cb3c68f3b4c675f9c964e21e 100644 (file)
@@ -1329,11 +1329,16 @@ leave_scope (void)
 
   /* Find the innermost enclosing class scope, and reset
      CLASS_BINDING_LEVEL appropriately.  */
-  for (scope = current_binding_level;
-       scope && scope->kind != sk_class;
-       scope = scope->level_chain)
-    ;
-  class_binding_level = scope && scope->kind == sk_class ? scope : NULL;
+  if (scope->kind == sk_class)
+    {
+      class_binding_level = NULL;
+      for (scope = current_binding_level; scope; scope = scope->level_chain)
+       if (scope->kind == sk_class)
+         {
+           class_binding_level = scope;
+           break;
+         }
+    }
 
   return current_binding_level;
 }