OSDN Git Service

Wed Mar 25 16:10:50 1998 Mark Mitchell <mmitchell@usa.net>
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Mar 1998 16:14:49 +0000 (16:14 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Mar 1998 16:14:49 +0000 (16:14 +0000)
* cp-tree.h (enforce_access): Declare.
* call.c (enforce_access): Make it extern, not static.
* class.c (alter_access): Use enforce_access; modify code for ISO
compliance, rather than ARM rules.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@18832 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/testsuite/g++.old-deja/g++.brendan/ns1.C
gcc/testsuite/g++.old-deja/g++.other/using1.C [new file with mode: 0644]

index 8c9a981..ba6309b 100644 (file)
@@ -1,3 +1,10 @@
+Wed Mar 25 16:10:50 1998  Mark Mitchell  <mmitchell@usa.net>
+
+       * cp-tree.h (enforce_access): Declare.
+       * call.c (enforce_access): Make it extern, not static.
+       * class.c (alter_access): Use enforce_access; modify code for ISO
+       compliance, rather than ARM rules.
+
 Wed Mar 25 12:10:45 1998  Kriang Lerdsuwanakij  <lerdsuwa@scf.usc.edu>
 
        * cp-tree.h: Fix typo.
index c74d1f4..8db795b 100644 (file)
@@ -51,7 +51,6 @@ static int compare_qual PROTO((tree, tree));
 static int compare_ics PROTO((tree, tree));
 static tree build_over_call PROTO((tree, tree, tree, int));
 static tree convert_default_arg PROTO((tree, tree));
-static void enforce_access PROTO((tree, tree));
 static tree convert_like PROTO((tree, tree));
 static void op_error PROTO((enum tree_code, enum tree_code, tree, tree,
                            tree, char *));
@@ -2949,26 +2948,26 @@ build_op_delete_call (code, addr, size, flags)
   return error_mark_node;
 }
 
-/* If the current scope isn't allowed to access FUNCTION along
+/* If the current scope isn't allowed to access DECL along
    BASETYPE_PATH, give an error.  */
 
-static void
-enforce_access (basetype_path, function)
-     tree basetype_path, function;
+void
+enforce_access (basetype_path, decl)
+     tree basetype_path, decl;
 {
-  tree access = compute_access (basetype_path, function);
+  tree access = compute_access (basetype_path, decl);
 
   if (access == access_private_node)
     {
-      cp_error_at ("`%+#D' is %s", function
-                  TREE_PRIVATE (function) ? "private"
+      cp_error_at ("`%+#D' is %s", decl
+                  TREE_PRIVATE (decl) ? "private"
                   : "from private base class");
       error ("within this context");
     }
   else if (access == access_protected_node)
     {
-      cp_error_at ("`%+#D' %s", function,
-                  TREE_PROTECTED (function) ? "is protected"
+      cp_error_at ("`%+#D' %s", decl,
+                  TREE_PROTECTED (decl) ? "is protected"
                   : "has protected accessibility");
       error ("within this context");
     }
index 37f8086..337c090 100644 (file)
@@ -1310,34 +1310,25 @@ alter_access (t, fdecl, access)
      tree access;
 {
   tree elem = purpose_member (t, DECL_ACCESS (fdecl));
-  if (elem && TREE_VALUE (elem) != access)
+  if (elem)
     {
-      if (TREE_CODE (TREE_TYPE (fdecl)) == FUNCTION_DECL)
+      if (TREE_VALUE (elem) != access)
        {
-         cp_error_at ("conflicting access specifications for method `%D', ignored", TREE_TYPE (fdecl));
+         if (TREE_CODE (TREE_TYPE (fdecl)) == FUNCTION_DECL)
+           cp_error_at ("conflicting access specifications for method `%D', ignored", TREE_TYPE (fdecl));
+         else
+           error ("conflicting access specifications for field `%s', ignored",
+                  IDENTIFIER_POINTER (DECL_NAME (fdecl)));
        }
       else
-       error ("conflicting access specifications for field `%s', ignored",
-              IDENTIFIER_POINTER (DECL_NAME (fdecl)));
-    }
-  else if (TREE_PRIVATE (fdecl))
-    {
-      if (access != access_private_node)
-       cp_error_at ("cannot make private `%D' non-private", fdecl);
-      goto alter;
+       /* They're changing the access to the same thing they changed
+          it to before.  That's OK.  */
+       ;
     }
-  else if (TREE_PROTECTED (fdecl))
-    {
-      if (access != access_protected_node)
-       cp_error_at ("cannot make protected `%D' non-protected", fdecl);
-      goto alter;
-    }
-  /* ARM 11.3: an access declaration may not be used to restrict access
-     to a member that is accessible in the base class.  */
-  else if (access != access_public_node)
-    cp_error_at ("cannot reduce access of public member `%D'", fdecl);
-  else if (elem == NULL_TREE)
+  else
     {
+      enforce_access (TYPE_BINFO (t), fdecl);
+
     alter:
       DECL_ACCESS (fdecl) = tree_cons (t, access, DECL_ACCESS (fdecl));
       return 1;
index 546fca0..9d76c9c 100644 (file)
@@ -2085,6 +2085,7 @@ extern tree build_op_new_call                     PROTO((enum tree_code, tree, tree, int));
 extern tree build_op_delete_call               PROTO((enum tree_code, tree, tree, int));
 extern int can_convert                         PROTO((tree, tree));
 extern int can_convert_arg                     PROTO((tree, tree, tree));
+extern void enforce_access                      PROTO((tree, tree));
 
 /* in class.c */
 extern tree build_vbase_path                   PROTO((enum tree_code, tree, tree, tree, int));
index 113f46b..d20a9d9 100644 (file)
@@ -2,7 +2,7 @@
 // GROUPS passed old-abort
 struct B 
 {
-      void f(char); // ERROR - Cannot reduce access
+      void f(char); 
       void g(char);
 };
   
diff --git a/gcc/testsuite/g++.old-deja/g++.other/using1.C b/gcc/testsuite/g++.old-deja/g++.other/using1.C
new file mode 100644 (file)
index 0000000..9e5615f
--- /dev/null
@@ -0,0 +1,26 @@
+class D2;
+
+class B {
+private:
+  int a;
+protected:
+  int b;
+
+  friend class D2;
+};
+
+class D : public B {
+public:
+  using B::a;
+  using B::b;
+};
+
+class D2 : public B {
+public:
+  using B::a;
+  using B::b;
+
+private:
+  using B::b; 
+}; // ERROR - conflicting access specifications