From: Iain Sandoe <iain@sandoe.co.uk>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [pushed] testsuite, Objective-C : Fix two plugin diagnostics tests for Darwin.
Date: Sun, 11 Oct 2020 16:09:36 +0100 [thread overview]
Message-ID: <5E0E1BBB-32DD-4A8B-A569-536F8AF1F033@sandoe.co.uk> (raw)
Hi
The @selector and @protocol keywords produce a var decl without
useful location information. The current diagnostics plugin does not
look at VAR_DECLs (and it would not be helpful if it did in this
case, since a single decl is shared across all the users).
However, we can, in this case, make expressions that produce useful
information.
tested across the Darwin range, and on x86_64-linux
pushed to master
thanks
Iain
gcc/testsuite/ChangeLog:
* objc.dg/plugin/diagnostic-test-expressions-1.m: Use assignment
expressions for @selector and @protocol to obtain a useful
diagnostic range.
---
.../plugin/diagnostic-test-expressions-1.m | 25 ++++++++++++++-----
1 file 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 ed7aca39a28..23a93021e83 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
--
2.24.1
reply other threads:[~2020-10-11 15:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5E0E1BBB-32DD-4A8B-A569-536F8AF1F033@sandoe.co.uk \
--to=iain@sandoe.co.uk \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).