summaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2001-03-26 08:37:27 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2001-03-26 08:37:27 +0000
commitcf8f00bf2b53c8f1766e5ddfc79ad5046e50d33e (patch)
treee80deebc6a447417a1ef0f9eae56f55fd7dabfbb /gcc/cp/semantics.c
parent64c65b3276f37a3ccfe47c11181e02913a68b16e (diff)
downloadgcc-cf8f00bf2b53c8f1766e5ddfc79ad5046e50d33e.tar.gz
cp:
Implement DR 209 * cp-tree.h (skip_type_access_control, reset_type_access_control): Prototype. * decl.c (grokdeclarator): Access of friends is not checked. * parse.y (component_decl_list): Reset type access control. * semantics.c (decl_type_access_control): Clear current_type_lookups. (save_type_access_control): Don't save if not deferring. (skip_type_access_control, reset_type_access_control): New functions. (begin_class_definition): Do type access control for basetypes. Start deferred access control. (finish_class_definition): Resume immediate access control if this is a local class. testsuite: * g++.old-deja/g++.other/friend12.C: New test. * g++.old-deja/g++.other/friend9.C: Expect no errors. * g++.old-deja/g++.robertl/eb56.C: Make typedef public. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@40841 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 6e037f4d727..c99a0db4e70 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1593,13 +1593,41 @@ decl_type_access_control (decl)
added to type_lookups after typed_declspecs saved the copy that
ended up in current_type_lookups. */
type_lookups = current_type_lookups;
+
+ current_type_lookups = NULL_TREE;
}
+/* Record the lookups, if we're doing deferred access control. */
+
void
save_type_access_control (lookups)
tree lookups;
{
- current_type_lookups = lookups;
+ if (type_lookups != error_mark_node)
+ {
+ my_friendly_assert (!current_type_lookups, 20010301);
+ current_type_lookups = lookups;
+ }
+ else
+ my_friendly_assert (!lookups || lookups == error_mark_node, 20010301);
+}
+
+/* Set things up so that the next deferred access control will succeed.
+ This is needed for friend declarations see grokdeclarator for details. */
+
+void
+skip_type_access_control ()
+{
+ type_lookups = NULL_TREE;
+}
+
+/* Reset the deferred access control. */
+
+void
+reset_type_access_control ()
+{
+ type_lookups = NULL_TREE;
+ current_type_lookups = NULL_TREE;
}
/* Begin a function definition declared with DECL_SPECS and
@@ -1732,6 +1760,10 @@ tree
begin_class_definition (t)
tree t;
{
+ /* Check the bases are accessible. */
+ decl_type_access_control (TYPE_NAME (t));
+ reset_type_access_control ();
+
if (processing_template_parmlist)
{
cp_error ("definition of `%#T' inside template parameter list", t);
@@ -1953,6 +1985,8 @@ finish_class_definition (t, attributes, semi, pop_scope_p)
check_for_missing_semicolon (t);
if (pop_scope_p)
pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t)));
+ if (current_function_decl)
+ type_lookups = error_mark_node;
if (current_scope () == current_function_decl)
do_pending_defargs ();