decl.c (grokdeclarator): Do type access control on friend class.
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 28 Nov 2000 10:06:16 +0000 (10:06 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 28 Nov 2000 10:06:16 +0000 (10:06 +0000)
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
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/friend9.C [new file with mode: 0644]

index 438f29a13dc5523d54998c0c599efd605930593a..fa0940110aaaab5d8c099c38cdfe60bfb2ffa857 100644 (file)
@@ -1,3 +1,8 @@
+2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * decl.c (grokdeclarator): Do type access control on friend
+       class.
+
 2000-11-27  Nathan Sidwell  <nathan@codesourcery.com>
 
        * decl.c (grokfndecl): Undo COMPONENT_REF damage caused by
index 3ca4ff6308487c4c5bdcb6d804dfa31ed5a544e9..da74687aa1a59a5b85cea9a6967065db6c55fc3a 100644 (file)
@@ -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;
            }
        }
index 1a46dff58c14ee2ce5c187ab491675a15fff30b5..66e472321a2b6b41dfdbcb2b335644f6f3845ffa 100644 (file)
@@ -1,10 +1,14 @@
+2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.old-deja/g++.other/friend9.C: New test.
+
 2000-11-28  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.dg/20001127-1.c: New test.
 
 2000-11-27  Nathan Sidwell  <nathan@codesourcery.com>
 
-       * g++.old-deja/g++.other/friend46.C: New test.
+       * g++.old-deja/g++.pt/friend46.C: New test.
 
 2000-11-27  Nathan Sidwell  <nathan@codesourcery.com>
 
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 (file)
index 0000000..442d989
--- /dev/null
@@ -0,0 +1,23 @@
+// Build don't link:
+
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 24 Nov 2000 <nathan@codesourcery.com>
+
+// 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();
+};