[C++ PATCH] Reorganize deferred access check code

Mark Mitchell mark@codesourcery.com
Mon Jan 13 16:35:00 GMT 2003



--On Monday, January 13, 2003 10:04:19 PM +0700 Kriang Lerdsuwanakij 
<lerdsuwa@users.sourceforge.net> wrote:

> + tree get_deferring_access_checks (void)
> + {
> +   return deferred_access_stack->deferred_access_checks;
> + }

This should be called get_deferred_access_checks.

+ void defer_access_check (tree class_type, tree decl)
+ {
+   tree check;
+
+   /* If we are not supposed to defer access checks, just check now.  */
+   if (!deferred_access_stack->deferring_access_checks_p)
+     {
+       enforce_access (class_type, decl);
+       return;
+     }

Here you perpetuated my bad naming convention; rename this function
"perform_or_defer_access_check".  (It doesn't always defer the check.)

With those changes, the patch is OK.  Thanks for the clean-ups.

The goal should be that access-control is performed (roughly) from the
parser and the template instantiation machinery and nowhere else.  Those
two pieces of code are responsible for looking up names, resolving them
to declarations, and then checking accessibility.  (One exception is that
overloaded functions aren't checked until we know which overloaded
function is being called, which happens later.)

In general, the YACC issues caused us to pass *names* (in the form of
TREE_IDENTIFIERs) into lots of functions that should really get DECLs
or TYPEs.  Once those functions are cleaned up, those functions no longer
need to be checking accessibility.

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com



More information about the Gcc-patches mailing list