diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2001-03-26 08:37:27 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2001-03-26 08:37:27 +0000 |
commit | 788bf0e34ebec318ef42f6a7ffd9e8632756908a (patch) | |
tree | e80deebc6a447417a1ef0f9eae56f55fd7dabfbb /gcc/cp/decl.c | |
parent | 04c5433d684a6e22d266a2bd067eb42e28ee9d60 (diff) | |
download | gcc-788bf0e34ebec318ef42f6a7ffd9e8632756908a.tar.gz |
Implement DR 209
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.
From-SVN: r40841
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 04d4c4ffc59..03f94a35fa1 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11131,7 +11131,9 @@ friend declaration requires class-key, i.e. `friend %#T'", /* Only try to do this stuff if we didn't already give up. */ if (type != integer_type_node) { - decl_type_access_control (TYPE_NAME (type)); + /* DR 209. The friendly class does not need to be accessible + in the scope of the class granting friendship. */ + skip_type_access_control (); /* A friendly class? */ if (current_class_type) @@ -11393,32 +11395,33 @@ friend declaration requires class-key, i.e. `friend %#T'", if (friendp) { /* Friends are treated specially. */ + tree t = NULL_TREE; + + /* DR 209. The friend does not need to be accessible at this + point. */ + skip_type_access_control (); + if (ctype == current_class_type) warning ("member functions are implicitly friends of their class"); - else - { - tree t = NULL_TREE; - if (decl && DECL_NAME (decl)) - { - if (template_class_depth (current_class_type) == 0) - { - decl - = check_explicit_specialization - (declarator, decl, - template_count, 2 * (funcdef_flag != 0) + 4); - if (decl == error_mark_node) - return error_mark_node; - } - t = do_friend (ctype, declarator, decl, - last_function_parms, attrlist, flags, quals, - funcdef_flag); - } - if (t && funcdef_flag) - return t; - - return void_type_node; - } + if (decl && DECL_NAME (decl)) + { + if (template_class_depth (current_class_type) == 0) + { + decl = check_explicit_specialization + (declarator, decl, + template_count, 2 * (funcdef_flag != 0) + 4); + if (decl == error_mark_node) + return error_mark_node; + } + + t = do_friend (ctype, declarator, decl, + last_function_parms, attrlist, flags, quals, + funcdef_flag); + } + if (t && funcdef_flag) + return t; + return void_type_node; } /* Structure field. It may not be a function, except for C++ */ |