diff options
author | Mark Mitchell <mmitchell@usa.net> | 1998-03-25 16:14:49 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1998-03-25 16:14:49 +0000 |
commit | 38afd588c5181ee770848ebefdfdb288d28f7513 (patch) | |
tree | e58cf50abaf2a215ebb006e333754dc7b6479657 /gcc | |
parent | 4d4c4d45832c47a303b322d11b25aea371c9f341 (diff) | |
download | gcc-38afd588c5181ee770848ebefdfdb288d28f7513.zip gcc-38afd588c5181ee770848ebefdfdb288d28f7513.tar.gz gcc-38afd588c5181ee770848ebefdfdb288d28f7513.tar.bz2 |
cp-tree.h (enforce_access): Declare.
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.
From-SVN: r18832
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/call.c | 19 | ||||
-rw-r--r-- | gcc/cp/class.c | 35 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.brendan/ns1.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/using1.C | 26 |
6 files changed, 57 insertions, 33 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8c9a981..ba6309b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index c74d1f4..8db795b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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"); } diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 37f8086..337c090 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -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; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 546fca0..9d76c9c 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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)); diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/ns1.C b/gcc/testsuite/g++.old-deja/g++.brendan/ns1.C index 113f46b..d20a9d9 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/ns1.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/ns1.C @@ -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 index 0000000..9e5615f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/using1.C @@ -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 + |