summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-17 21:52:09 +0000
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-17 21:52:09 +0000
commitf15f2e565f60086a06501385a941899fb4b6fb7b (patch)
tree2d6e2e2e27434afe6a8c78faa3fe2eabe7e5ee36 /gcc
parentb1572e0950a6dba2398648f0781cdbd669b8413f (diff)
downloadgcc-f15f2e565f60086a06501385a941899fb4b6fb7b.tar.gz
In gcc/:
2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com> Merge from 'apple/trunk' branch on FSF servers. 2006-03-27 Fariborz Jahanian <fjahanian@apple.com> Radar 4133425 * c-decl.c (undeclared_variable): Issue diagnostic on private 'ivar' access. In gcc/c-family/: 2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com> Merge from 'apple/trunk' branch on FSF servers. 2006-03-27 Fariborz Jahanian <fjahanian@apple.com> Radar 4133425 * c-common.h (objc_diagnose_private_ivar): New decl. * stub-objc.c (objc_diagnose_private_ivar): New stub. In gcc/cp/: 2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com> Merge from apple/trunk branch on FSF servers. 2006-03-27 Fariborz Jahanian <fjahanian@apple.com> Radar 4133425 * lex.c (unqualified_name_lookup_error): Issue diagnostic for private 'ivar' access. In gcc/objc/: 2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com> Merge from 'apple/trunk' branch on FSF servers. 2006-03-27 Fariborz Jahanian <fjahanian@apple.com> Radar 4133425 * objc-act.c (objc_diagnose_private_ivar): New. In gcc/testsuite/: 2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com> Merge from 'apple/trunk' branch on FSF servers. 2006-03-27 Fariborz Jahanian <fjahanian@apple.com> Radar 4133425 * objc.dg/private-1.m: Test modified. * obj-c++.dg/private-1.mm: Test modified. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165601 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/c-decl.c3
-rw-r--r--gcc/c-family/ChangeLog10
-rw-r--r--gcc/c-family/c-common.h1
-rw-r--r--gcc/c-family/stub-objc.c5
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/lex.c3
-rw-r--r--gcc/objc/ChangeLog9
-rw-r--r--gcc/objc/objc-act.c19
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/obj-c++.dg/private-1.mm4
-rw-r--r--gcc/testsuite/objc.dg/private-1.m2
12 files changed, 80 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0eb36e66154..5bfe507ac02 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ Merge from 'apple/trunk' branch on FSF servers.
+
+ 2006-03-27 Fariborz Jahanian <fjahanian@apple.com>
+
+ Radar 4133425
+ * c-decl.c (undeclared_variable): Issue diagnostic on
+ private 'ivar' access.
+
2010-10-17 Uros Bizjak <ubizjak@gmail.com>
PR target/46051
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index acb00d46369..c1a44d8eb57 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -2961,7 +2961,8 @@ undeclared_variable (location_t loc, tree id)
}
else
{
- error_at (loc, "%qE undeclared (first use in this function)", id);
+ if (!objc_diagnose_private_ivar (id))
+ error_at (loc, "%qE undeclared (first use in this function)", id);
if (!already)
{
inform (loc, "each undeclared identifier is reported only"
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index f0ef49e0171..ec54c09e659 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ Merge from 'apple/trunk' branch on FSF servers.
+
+ 2006-03-27 Fariborz Jahanian <fjahanian@apple.com>
+
+ Radar 4133425
+ * c-common.h (objc_diagnose_private_ivar): New decl.
+ * stub-objc.c (objc_diagnose_private_ivar): New stub.
+
2010-10-17 Iain Sandoe <iains@gcc.gnu.org>
* c-common.c (c_common_reswords): Add package, RID_AT_PACKAGE.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 8855ff794d3..2a58c6c73d3 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -987,6 +987,7 @@ extern void objc_check_global_decl (tree);
extern tree objc_common_type (tree, tree);
extern bool objc_compare_types (tree, tree, int, tree);
extern bool objc_have_common_type (tree, tree, int, tree);
+extern bool objc_diagnose_private_ivar (tree);
extern void objc_volatilize_decl (tree);
extern bool objc_type_quals_match (tree, tree);
extern tree objc_rewrite_function_call (tree, tree);
diff --git a/gcc/c-family/stub-objc.c b/gcc/c-family/stub-objc.c
index cff4d79267e..c6a8cfad4e6 100644
--- a/gcc/c-family/stub-objc.c
+++ b/gcc/c-family/stub-objc.c
@@ -44,6 +44,11 @@ objc_is_object_ptr (tree ARG_UNUSED (arg))
return 0;
}
+bool objc_diagnose_private_ivar (tree ARG_UNUSED (arg))
+{
+ return false;
+}
+
tree
objc_lookup_ivar (tree other, tree ARG_UNUSED (arg))
{
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b72d43d2ae6..fc26e00d34f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ Merge from apple/trunk branch on FSF servers.
+
+ 2006-03-27 Fariborz Jahanian <fjahanian@apple.com>
+
+ Radar 4133425
+ * lex.c (unqualified_name_lookup_error): Issue diagnostic
+ for private 'ivar' access.
+
2010-10-17 Iain Sandoe <iains@gcc.gnu.org>
* parser.c (cp_parser_objc_visibility_spec): Update to use visibility
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 8a894c743ba..c583d7d307e 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -449,7 +449,8 @@ unqualified_name_lookup_error (tree name)
}
else
{
- error ("%qD was not declared in this scope", name);
+ if (!objc_diagnose_private_ivar (name))
+ error ("%qD was not declared in this scope", name);
/* Prevent repeated error messages by creating a VAR_DECL with
this NAME in the innermost block scope. */
if (current_function_decl)
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index 7917d60fa9b..83bef4deecb 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,3 +1,12 @@
+2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ Merge from 'apple/trunk' branch on FSF servers.
+
+ 2006-03-27 Fariborz Jahanian <fjahanian@apple.com>
+
+ Radar 4133425
+ * objc-act.c (objc_diagnose_private_ivar): New.
+
2010-10-17 Iain Sandoe <iains@gcc.gnu.org>
* objc-act.c: Rename 'objc_public_flag' to objc_ivar_visibility and
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 1be52d91b5c..904095495db 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -10821,6 +10821,25 @@ generate_objc_image_info (void)
finish_var_decl (decl, objc_build_constructor (TREE_TYPE (decl), v));
}
+/* Routine is called to issue diagnostic when reference to a private
+ ivar is made and no other variable with same name is found in
+ current scope. */
+bool
+objc_diagnose_private_ivar (tree id)
+{
+ tree ivar;
+ if (!objc_method_context)
+ return false;
+ ivar = is_ivar (objc_ivar_chain, id);
+ if (ivar && is_private (ivar))
+ {
+ error ("instance variable %qs is declared private",
+ IDENTIFIER_POINTER (id));
+ return true;
+ }
+ return false;
+}
+
/* Look up ID as an instance variable. OTHER contains the result of
the C or C++ lookup, which we may want to use instead. */
/* Also handle use of property as setter/getter. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f50d9f3e817..dfdaa82e26e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ Merge from 'apple/trunk' branch on FSF servers.
+
+ 2006-03-27 Fariborz Jahanian <fjahanian@apple.com>
+
+ Radar 4133425
+ * objc.dg/private-1.m: Test modified.
+ * obj-c++.dg/private-1.mm: Test modified.
+
2010-10-17 Uros Bizjak <ubizjak@gmail.com>
PR testsuite/45987
diff --git a/gcc/testsuite/obj-c++.dg/private-1.mm b/gcc/testsuite/obj-c++.dg/private-1.mm
index c4ec5ffb9b1..cd423b55127 100644
--- a/gcc/testsuite/obj-c++.dg/private-1.mm
+++ b/gcc/testsuite/obj-c++.dg/private-1.mm
@@ -1,8 +1,6 @@
/* Test errors for accessing @private and @protected variables. */
/* Based on work by: Nicola Pero <nicola@brainstorm.co.uk>. */
-
/* { dg-do compile } */
-
#include <objc/objc.h>
@interface MySuperClass
@@ -36,7 +34,7 @@
- (void) test
{
/* Private variables simply don't exist in the subclass. */
- _private = 12; /* { dg-error "._private. was not declared in this scope" } */
+ _private = 12; /* { dg-error "instance variable \\'_private\\' is declared private" } */
_protected = 12; /* Ok */
_public = 12; /* Ok */
diff --git a/gcc/testsuite/objc.dg/private-1.m b/gcc/testsuite/objc.dg/private-1.m
index 59cff1583bd..a11183c8ea6 100644
--- a/gcc/testsuite/objc.dg/private-1.m
+++ b/gcc/testsuite/objc.dg/private-1.m
@@ -34,7 +34,7 @@
- (void) test
{
/* Private variables simply don't exist in the subclass. */
- private = 12;/* { dg-error "undeclared" } */
+ private = 12; /* { dg-error "instance variable" } */
/* { dg-message "function it appears in" "" { target *-*-* } { 37 } } */
protected = 12; /* Ok */