diff options
-rw-r--r-- | gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m b/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m index ed7aca3..23a9302 100644 --- a/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m +++ b/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m @@ -5,6 +5,8 @@ (see the notes in that file); this file adds test coverage for various Objective C constructs. */ +#include <objc/runtime.h> /* for SEL, Protocol */ + extern void __emit_expression_range (int dummy, ...); @protocol prot @@ -55,22 +57,33 @@ extern void __emit_expression_range (int dummy, ...); ~~~~~~~~~~~ { dg-end-multiline-output "" } */ } + - (void) test_at_selector { - __emit_expression_range ( 0, @selector(func0) ); /* { dg-warning "range" } */ + /* For the NeXT runtime, @selector() generates a a var decl which (a) isn't + handled by the plugin, and (b) if it was would not necessarily have the + right location (there is only one var decl uniqued to each selector + spelling, so the location would be that of the first occurrence). Use an + assignment expression to test the operation. */ + SEL aSel; + __emit_expression_range ( 0, aSel = @selector(foo) ); /* { dg-warning "range" } */ /* { dg-begin-multiline-output "" } - __emit_expression_range ( 0, @selector(func0) ); - ^~~~~~~~~~~~~~~~ + __emit_expression_range ( 0, aSel = @selector(foo) ); + ~~~~~^~~~~~~~~~~~~~~~ { dg-end-multiline-output "" } */ } - (void) test_at_protocol { - __emit_expression_range ( 0, @protocol(prot) ); /* { dg-warning "range" } */ + /* As for @selector(), the NeXT runtime generates a a var decl for + @protocol() handle this in a similar way. */ + Protocol *aProt; + __emit_expression_range ( 0, aProt = @protocol(prot) ); /* { dg-warning "range" "" } */ /* { dg-begin-multiline-output "" } - __emit_expression_range ( 0, @protocol(prot) ); - ~~~~~~~~~~~~~~~ + __emit_expression_range ( 0, aProt = @protocol(prot) ); + ~~~~~~^~~~~~~~~~~~~~~~~ { dg-end-multiline-output "" } */ } + - (void) test_at_encode:(int)i { /* @encode() generates a STRING_CST which doesn't retain a location |