+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.
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 *));
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");
}
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;
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));
// GROUPS passed old-abort
struct B
{
- void f(char); // ERROR - Cannot reduce access
+ void f(char);
void g(char);
};
--- /dev/null
+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
+