From 5ee4cc26fbaccd529679ca56cd1086aa62bc9902 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 28 Nov 2000 10:06:16 +0000 Subject: [PATCH] decl.c (grokdeclarator): Do type access control on friend class. cp: * decl.c (grokdeclarator): Do type access control on friend class. testsuite: * g++.old-deja/g++.other/friend9.C: New test. From-SVN: r37814 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/decl.c | 3 +++ gcc/testsuite/ChangeLog | 6 ++++- .../g++.old-deja/g++.other/friend9.C | 23 +++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/friend9.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 438f29a13dc..fa0940110aa 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-11-28 Nathan Sidwell + + * decl.c (grokdeclarator): Do type access control on friend + class. + 2000-11-27 Nathan Sidwell * decl.c (grokfndecl): Undo COMPONENT_REF damage caused by diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3ca4ff63084..da74687aa1a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11305,12 +11305,15 @@ 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)); + /* A friendly class? */ if (current_class_type) make_friend_class (current_class_type, TYPE_MAIN_VARIANT (type)); else cp_error ("trying to make class `%T' a friend of global scope", type); + type = void_type_node; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1a46dff58c1..66e472321a2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,10 +1,14 @@ +2000-11-28 Nathan Sidwell + + * g++.old-deja/g++.other/friend9.C: New test. + 2000-11-28 Jakub Jelinek * gcc.dg/20001127-1.c: New test. 2000-11-27 Nathan Sidwell - * g++.old-deja/g++.other/friend46.C: New test. + * g++.old-deja/g++.pt/friend46.C: New test. 2000-11-27 Nathan Sidwell diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend9.C b/gcc/testsuite/g++.old-deja/g++.other/friend9.C new file mode 100644 index 00000000000..442d9899e3a --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/friend9.C @@ -0,0 +1,23 @@ +// Build don't link: + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 24 Nov 2000 + +// Bug 853: We reported the wrong line no for a friend access violation + +class F +{ + class Internal; // ERROR - is private +}; + +class C +{ + friend class F::Internal; // ERROR - in this context + public: + typedef enum { A, B } e; + + C (); + ~C(); + + void m(); +}; -- 2.30.2