* ObjC: fix location of "iterating variable is not an object" for fast enumeration
@ 2010-12-08 23:04 Nicola Pero
2010-12-08 23:36 ` Mike Stump
0 siblings, 1 reply; 2+ messages in thread
From: Nicola Pero @ 2010-12-08 23:04 UTC (permalink / raw)
To: gcc-patches
This improves error messages generated by invalid Objective-C code such as
for (int i in array)
{
...
}
before this patch, the "iterating variable is not an object" error was located on the line
containing '{', which is confusing. This patch changes the error to be on the right line.
Ok to commit ?
Thanks
Index: objc/objc-act.c
===================================================================
--- objc/objc-act.c (revision 167598)
+++ objc/objc-act.c (working copy)
@@ -13246,13 +13246,13 @@ objc_finish_foreach_loop (location_t location, tre
if (!objc_type_valid_for_messaging (TREE_TYPE (object_expression), true))
{
- error ("iterating variable in fast enumeration is not an object");
+ error_at (location, "iterating variable in fast enumeration is not an object");
return;
}
if (!objc_type_valid_for_messaging (TREE_TYPE (collection_expression), true))
{
- error ("collection in fast enumeration is not an object");
+ error_at (location, "collection in fast enumeration is not an object");
return;
}
Index: objc/ChangeLog
===================================================================
--- objc/ChangeLog (revision 167598)
+++ objc/ChangeLog (working copy)
@@ -1,3 +1,9 @@
+2010-12-08 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * objc-act.c (objc_finish_foreach_loop): Use error_at() instead of
+ error() when printing an error about the iterating variable or
+ collection not being an object.
+
2010-12-06 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_finish_foreach_loop): Mark the
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (revision 167598)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2010-12-08 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * objc.dg/foreach-6.m: Updated location of error messages.
+ * objc.dg/foreach-7.m: Same change.
+
2010-12-08 Wei Guozhi <carrot@google.com>
PR target/46631
Index: testsuite/objc.dg/foreach-6.m
===================================================================
--- testsuite/objc.dg/foreach-6.m (revision 167607)
+++ testsuite/objc.dg/foreach-6.m (working copy)
@@ -46,16 +46,16 @@ int main (void)
;
for (12 in array) /* { dg-error "invalid iterating variable in fast enumeration" } */
- ; /* { dg-error "iterating variable in fast enumeration is not an object" } */
+ ; /* { dg-error "iterating variable in fast enumeration is not an object" "" { target *-*-* } 48 } */
- for (object in 12)
- ; /* { dg-error "collection in fast enumeration is not an object" } */
+ for (object in 12) /* { dg-error "collection in fast enumeration is not an object" } */
+ ;
- for (object in invalid)
- ; /* { dg-error "collection in fast enumeration is not an object" } */
+ for (object in invalid) /* { dg-error "collection in fast enumeration is not an object" } */
+ ;
- for (invalid in [object enumerator])
- ; /* { dg-error "iterating variable in fast enumeration is not an object" } */
+ for (invalid in [object enumerator]) /* { dg-error "iterating variable in fast enumeration is not an object" } */
+ ;
return 0;
}
Index: testsuite/objc.dg/foreach-7.m
===================================================================
--- testsuite/objc.dg/foreach-7.m (revision 167607)
+++ testsuite/objc.dg/foreach-7.m (working copy)
@@ -36,10 +36,10 @@ int main (void)
id object = nil;
for (typedef int my_typedef in array) /* { dg-error "declaration of non-variable" } */
- ; /* { dg-error "iterating variable in fast enumeration is not an object" } */
+ ; /* { dg-error "iterating variable in fast enumeration is not an object" "" { target *-*-* } 38 } */
for (function () in nil) /* { dg-error "invalid iterating variable in fast enumeration" } */
- ; /* { dg-error "iterating variable in fast enumeration is not an object" } */
+ ; /* { dg-error "iterating variable in fast enumeration is not an object" "" { target *-*-* } 41 } */
for (object_function () in nil) /* { dg-error "invalid iterating variable in fast enumeration" } */
;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: ObjC: fix location of "iterating variable is not an object" for fast enumeration
2010-12-08 23:04 ObjC: fix location of "iterating variable is not an object" for fast enumeration Nicola Pero
@ 2010-12-08 23:36 ` Mike Stump
0 siblings, 0 replies; 2+ messages in thread
From: Mike Stump @ 2010-12-08 23:36 UTC (permalink / raw)
To: Nicola Pero; +Cc: gcc-patches
On Dec 8, 2010, at 2:18 PM, Nicola Pero wrote:
> This improves error messages generated by invalid Objective-C code such as
>
> for (int i in array)
> {
> ...
> }
>
> before this patch, the "iterating variable is not an object" error was located on the line
> containing '{', which is confusing. This patch changes the error to be on the right line.
>
> Ok to commit ?
Ok.
That said, I'd prefer avoiding the line numbers in the testcases if possible. That said, I don't see an easy way around this here.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-12-08 23:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-08 23:04 ObjC: fix location of "iterating variable is not an object" for fast enumeration Nicola Pero
2010-12-08 23:36 ` Mike Stump
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).