diff options
author | Nicola Pero <nicola@brainstorm.co.uk> | 2004-06-01 07:40:02 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2004-06-01 07:40:02 +0000 |
commit | 61c627ed2c1b7184807d2101ab2d288e9ca4f39b (patch) | |
tree | 139086f8092179d1478c674d6dd17965d6d53178 /gcc/objc/objc-act.c | |
parent | d314442396916fa65739d6baeb24b2f0cfc76634 (diff) | |
download | gcc-61c627ed2c1b7184807d2101ab2d288e9ca4f39b.zip gcc-61c627ed2c1b7184807d2101ab2d288e9ca4f39b.tar.gz gcc-61c627ed2c1b7184807d2101ab2d288e9ca4f39b.tar.bz2 |
re PR objc/7993 (private variables cannot be shadowed in subclasses)
2004-06-01 Nicola Pero <nicola@brainstorm.co.uk>
Fix PR objc/7993:
* objc-act.c (is_private): Do not emit the 'instance variable %s
is declared private' error.
(is_public): Emit the error after calling is_private.
(lookup_objc_ivar): If the instance variable is private, return 0
- the instance variable is invisible here.
testsuite:
* objc.dg/private-1.m, objc-dg/private-2.m: New testcases.
From-SVN: r82532
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r-- | gcc/objc/objc-act.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 385360a..0707433 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -6467,15 +6467,9 @@ is_ivar (tree decl_chain, tree ident) int is_private (tree decl) { - if (TREE_PRIVATE (decl) - && ! is_ivar (CLASS_IVARS (implementation_template), DECL_NAME (decl))) - { - error ("instance variable `%s' is declared private", - IDENTIFIER_POINTER (DECL_NAME (decl))); - return 1; - } - else - return 0; + return (TREE_PRIVATE (decl) + && ! is_ivar (CLASS_IVARS (implementation_template), + DECL_NAME (decl))); } /* We have an instance variable reference;, check to see if it is public. */ @@ -6513,7 +6507,14 @@ is_public (tree expr, tree identifier) == CATEGORY_IMPLEMENTATION_TYPE)) && (CLASS_NAME (objc_implementation_context) == OBJC_TYPE_NAME (basetype)))) - return ! is_private (decl); + { + int private = is_private (decl); + + if (private) + error ("instance variable `%s' is declared private", + IDENTIFIER_POINTER (DECL_NAME (decl))); + return !private; + } /* The 2.95.2 compiler sometimes allowed C functions to access non-@public ivars. We will let this slide for now... */ @@ -9066,7 +9067,7 @@ lookup_objc_ivar (tree id) else if (objc_method_context && (decl = is_ivar (objc_ivar_chain, id))) { if (is_private (decl)) - return error_mark_node; + return 0; else return build_ivar_reference (id); } |