diff options
author | Nicola Pero <n.pero@mi.flashnet.it> | 2002-08-27 23:57:47 +0200 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2002-08-27 21:57:47 +0000 |
commit | ece4ce85d8c9b38cd2d5cec1c75727102208b20d (patch) | |
tree | 1efb184e0cd44cf2aac37370cf4d5a447a672355 /gcc/objc | |
parent | ac2a2d6f2f7017e24ed27845af4d48bfc3ba1e4f (diff) | |
download | gcc-ece4ce85d8c9b38cd2d5cec1c75727102208b20d.zip gcc-ece4ce85d8c9b38cd2d5cec1c75727102208b20d.tar.gz gcc-ece4ce85d8c9b38cd2d5cec1c75727102208b20d.tar.bz2 |
Added -Wundeclared-selector ObjC command line option
From-SVN: r56615
Diffstat (limited to 'gcc/objc')
-rw-r--r-- | gcc/objc/objc-act.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 0819369..7a1f82b 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -5105,6 +5105,9 @@ build_protocol_expr (protoname) return expr; } +/* This function is called by the parser when a @selector() expression + is found, in order to compile it. It is only called by the parser + and only to compile a @selector(). */ tree build_selector_expr (selnamelist) tree selnamelist; @@ -5120,6 +5123,32 @@ build_selector_expr (selnamelist) else abort (); + /* If we are required to check @selector() expressions as they + are found, check that the selector has been declared. */ + if (warn_undeclared_selector) + { + /* Look the selector up in the list of all known class and + instance methods (up to this line) to check that the selector + exists. */ + hash hsh; + + /* First try with instance methods. */ + hsh = hash_lookup (nst_method_hash_list, selname); + + /* If not found, try with class methods. */ + if (!hsh) + { + hsh = hash_lookup (cls_method_hash_list, selname); + } + + /* If still not found, print out a warning. */ + if (!hsh) + { + warning ("undeclared selector `%s'", IDENTIFIER_POINTER (selname)); + } + } + + if (flag_typed_selectors) return build_typed_selector_reference (selname, 0); else @@ -5259,6 +5288,7 @@ lookup_method (mchain, method) { if (METHOD_SEL_NAME (mchain) == key) return mchain; + mchain = TREE_CHAIN (mchain); } return NULL_TREE; |