+2003-05-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ * semantics.c (perform_deferred_access_checks): Don't discard
+ checked access.
+
2003-05-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* error.c (cp_error_at, cp_warning_at, cp_pedwarn_at): Eliminate
pop_deferring_access_checks ();
}
-/* Perform the deferred access checks. */
+/* Perform the deferred access checks.
+
+ After performing the checks, we still have to keep the list
+ `deferred_access_stack->deferred_access_checks' since we may want
+ to check access for them again later in a different context.
+ For example:
+
+ class A {
+ typedef int X;
+ static X a;
+ };
+ A::X A::a, x; // No error for `A::a', error for `x'
+
+ We have to perform deferred access of `A::X', first with `A::a',
+ next with `x'. */
void perform_deferred_access_checks (void)
{
/* Check access. */
enforce_access (TREE_PURPOSE (deferred_check),
TREE_VALUE (deferred_check));
-
- /* No more deferred checks. */
- deferred_access_stack->deferred_access_checks = NULL_TREE;
}
/* Defer checking the accessibility of DECL, when looked up in
+2003-05-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ * g++.dg/parse/access2.C: New test.
+
2003-05-17 Mark Mitchell <mark@codesourcery.com>
* lib/gcc-dg.exp (gcc-dg-debug-runtest): New method.
--- /dev/null
+// Copyright (C) 2003 Free Software Foundation
+// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+// { dg-do compile }
+
+// Deferred access checking of variable declaration.
+
+class A {
+ typedef int X; // { dg-error "private" }
+ static X a, b, c;
+};
+
+A::X A::a;
+A::X A::b, x; // { dg-error "this context" }
+A::X y, A::c; // { dg-error "this context" }
+A::X z; // { dg-error "this context" }