re PR middle-end/7651 (Define -Wextra strictly in terms of other warning flags)
[gcc.git] / gcc / testsuite / objc.dg / method-17.m
1 /* Test for spurious "may or may not return a value" warnings. */
2
3 /* { dg-do compile } */
4 /* { dg-options "-Wreturn-type -Wextra" } */
5
6 #include <objc/Object.h>
7
8 @interface Foo: Object
9 - (id) meth1;
10 - (void) meth2;
11 @end
12
13 extern int bar;
14
15 @implementation Foo
16 - (id) meth1 {
17 if (bar)
18 return [Object new];
19 return; /* { dg-warning "'return' with no value, in function returning non-void" } */
20 }
21 - (void) meth2 {
22 if (!bar)
23 return;
24 bar = 0;
25 } /* { dg-bogus "'return' with no value, in function returning non-void" } */
26 @end