This is the mail archive of the gcc-patches@gcc.gnu.org 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 08:43 PM, Nicola Pero wrote:

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:

Thanks - you are right - I hadn't noticed that.


The C and Objective-C compilers should really behave identically when
parsing non-Objective-C things (such as a standard 'for' loop).  If
your patch intentionally breaks that, it's a problem. ;-)

I accepted to deviate a bit from this good rule for "for" loops, since Objective-C is not a superset of C there:


int f()
{
        for (int in = 0; ; )
                ;
}

gives

f.c:3:11: error: expected identifier or â(â before âinâ

in Objective-C. I think foreach syntax is a very bad idea, though not your fault of course. "for (x : a)" would have been much better.

I think you should add the missing checks that you describe to restore
having the same behaviour in C and Objective-C; it probably would have
taken you less time to fix your patch than to write the changes in an
email to get me to fix it for you ;-)

I can do that. However, not that it's only a matter of which errors you get. My patch does not affect which valid C code is invalid Objective-C. (Part of the idea of the mail was also to document all this for teh Google, otherwise I might as well have written it in Italian ;).


But you're actually worrying me as I'm now fearful that many more differences
between C and ObjC may have been introduced.

Not by me (this one was intentional, and I didn't touch Objective-C very much), but...


Maybe we should run the C
testsuite with the compiler in ObjC mode ?

... this is a good idea.


Paolo


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