This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Selector warning


On Thursday, August 1, 2002, at 02:43  PM, Graham Stott wrote:

A few more style issues.
oops. Here we go again...
-Devang

2002-01-08 Devang Patel <dpatel@apple.com>
* objc/objc-act.c (build_selector_translation_table): Issue warning, when
-Wselector is used,if method for which selector is being created does not exist.

testsuite:
*objc.dg/selector-1.m : New test

Index: objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.147
diff -c -3 -p -r1.147 objc-act.c
*** objc-act.c 1 Aug 2002 15:43:51 -0000 1.147
--- objc-act.c 1 Aug 2002 21:51:22 -0000
*************** build_selector_translation_table ()
*** 1927,1932 ****
--- 1927,1958 ----
{
tree expr;

+ if (warn_selector && objc_implementation_context)
+ {
+ tree method_chain;
+ bool found = false;
+ for (method_chain = meth_var_names_chain;
+ method_chain;
+ method_chain = TREE_CHAIN (method_chain))
+ {
+ if (TREE_VALUE (method_chain) == TREE_VALUE (chain))
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ /* Adjust line number for warning message. */
+ int save_lineno = lineno;
+ if (flag_next_runtime && TREE_PURPOSE (chain))
+ lineno = DECL_SOURCE_LINE (TREE_PURPOSE (chain));
+ warning ("creating selector for non existant method %s",
+ IDENTIFIER_POINTER (TREE_VALUE (chain)));
+ lineno = save_lineno;
+ }
+ }
+
expr = build_selector (TREE_VALUE (chain));

if (flag_next_runtime)

Index: selector-1.m
===================================================================
RCS file: selector-1.m
diff -N selector-1.m
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- selector-1.m 1 Aug 2002 21:09:56 -0000
***************
*** 0 ****
--- 1,26 ----
+ /* Test warning for non existing selectors. */
+ /* Contributed by Devang Patel <dpatel@apple.com>. */
+ /* { dg-options "-Wselector -fnext-runtime" } */
+ /* { dg-do compile } */
+
+ typedef struct objc_object { struct objc_class *class_pointer; } *id;
+ typedef struct objc_selector *SEL;
+
+ @interface Foo
+ - (void) foo;
+ - (void) bar;
+ @end
+
+ @implementation Foo
+ - (void) bar
+ {
+ }
+
+ - (void) foo
+ {
+ SEL a,b,c;
+ a = @selector(b1ar); /* { dg-warning "creating selector for non existant method b1ar" } */
+ b = @selector(bar);
+ }
+ @end
+



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]