This is the mail archive of the 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] fix Objective-C, further improve error recovery for unknown type names

On 11/13/2010 07:38 PM, Nicola Pero wrote:
I would change that to always set objc_could_be_foreach_context to 'true'; in C,
it has not effect, so it does no matter what you set it to.  But if you always set it to
'true', then the nice assert that you added a few lines later to check that
objc_could_be_foreach_context is always set back to 'false' --

+ gcc_assert(!parser->objc_could_be_foreach_context);

gets always exercised when you run the C testsuite, which means that we are confident that objc_could_be_foreach_context is always restored to 'false' after parsing a C "for" loop (which is also a valid ObjC "for" loop). :-)

You are right. However, there would be a subtle change, in that the shiny new unknown type name error would be disabled in C 'for' loop initial declarations, same as it is disabled for Objective C:

$ cat f.c
int f()
	for (intt i = 1; i < 10; i++)

$ ./cc1 f.c -std=c99 -quiet
f.c: In function âfâ:
f.c:3:7: error: unknown type name âinttâ

$ ./cc1obj f.c -std=c99 -quiet
f.c:3:7: error: âinttâ undeclared (first use in this function)
f.c:3:12: error: expected â;â before âiâ
f.c:3:19: error: âiâ undeclared (first use in this function)

This can be fixed by adding a c_dialect_objc check to c_parser_next_tokens_start_declaration (after which you can do what you suggest). You can even get the new error to work for ObjC if you check for RID_IN. However, I'll leave it for a separate patch, possibly written by somebody with more interest in Objective-C. :)


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