aboutsummaryrefslogtreecommitdiff
path: root/gcc/objc/objc-act.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r--gcc/objc/objc-act.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index cb0b5ac..cda345b 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -226,7 +226,7 @@ struct imp_entry *imp_list = 0;
int imp_count = 0; /* `@implementation' */
int cat_count = 0; /* `@category' */
-objc_ivar_visibility_kind objc_ivar_visibility;
+objc_ivar_visibility_kind objc_ivar_visibility, objc_default_ivar_visibility;
/* Use to generate method labels. */
static int method_slot = 0;
@@ -394,6 +394,22 @@ objc_init (void)
if (!ok)
return false;
+ /* Determine the default visibility for instance variables. */
+ switch (default_ivar_visibility)
+ {
+ case IVAR_VISIBILITY_PRIVATE:
+ objc_default_ivar_visibility = OBJC_IVAR_VIS_PRIVATE;
+ break;
+ case IVAR_VISIBILITY_PUBLIC:
+ objc_default_ivar_visibility = OBJC_IVAR_VIS_PUBLIC;
+ break;
+ case IVAR_VISIBILITY_PACKAGE:
+ objc_default_ivar_visibility = OBJC_IVAR_VIS_PACKAGE;
+ break;
+ default:
+ objc_default_ivar_visibility = OBJC_IVAR_VIS_PROTECTED;
+ }
+
/* Generate general types and push runtime-specific decls to file scope. */
synth_module_prologue ();
@@ -568,7 +584,7 @@ objc_start_class_interface (tree klass, tree super_class,
objc_interface_context
= objc_ivar_context
= start_class (CLASS_INTERFACE_TYPE, klass, super_class, protos, attributes);
- objc_ivar_visibility = OBJC_IVAR_VIS_PROTECTED;
+ objc_ivar_visibility = objc_default_ivar_visibility;
}
void
@@ -646,7 +662,7 @@ objc_start_class_implementation (tree klass, tree super_class)
= objc_ivar_context
= start_class (CLASS_IMPLEMENTATION_TYPE, klass, super_class, NULL_TREE,
NULL_TREE);
- objc_ivar_visibility = OBJC_IVAR_VIS_PROTECTED;
+ objc_ivar_visibility = objc_default_ivar_visibility;
}
void
@@ -9366,6 +9382,12 @@ objc_lookup_ivar (tree other, tree id)
&& other && other != error_mark_node)
return other;
+ /* Don't look up the ivar if the user has explicitly advised against
+ it with -fno-local-ivars. */
+
+ if (!flag_local_ivars)
+ return other;
+
/* Look up the ivar, but do not use it if it is not accessible. */
ivar = is_ivar (objc_ivar_chain, id);
@@ -9382,8 +9404,11 @@ objc_lookup_ivar (tree other, tree id)
&& !DECL_FILE_SCOPE_P (other))
#endif
{
- warning (0, "local declaration of %qE hides instance variable", id);
-
+ if (warn_shadow_ivar == 1 || (warn_shadow && warn_shadow_ivar != 0)) {
+ warning (warn_shadow_ivar ? OPT_Wshadow_ivar : OPT_Wshadow,
+ "local declaration of %qE hides instance variable", id);
+ }
+
return other;
}