Are synthesised Objective-C types needed?

Hi,

I've been having problems with the type of SEL in Sema.cpp being hard-coded to the type used by the NeXT runtime (on GNU it is const, and so you now get an error compiling any Objective-C program anywhere except Darwin because there is a type conflict).

Looking at the headers, on both Cocoa and GNUstep Foundation.h includes <objc/objc.h> before any Objective-C headers. Objective-C programs which don't include Foundation.h as their first include, which provides definitions for SEL, Protocol, id, Class, IMP and MetaClass. It seems like some duplicated effort to synthesise them when every Objective-C program will also force the definitions to be parsed (Objective-C programs which don't use Foundation either include this header themselves or include <objc/Object.h>, which, in turn, includes it.

With GCC, they are not hard-coded:

$ cat test.m && gcc test.m
int main(void)
{
         SEL d;
         return 0;
}
test.m: In function 'main':
test.m:3: error: 'SEL' undeclared (first use in this function)
test.m:3: error: (Each undeclared identifier is reported only once
test.m:3: error: for each function it appears in.)
test.m:3: error: expected ';' before 'd'

It seems that value in ASTContext for a SEL type is used in a few places, so ideally we would lazily look this up from whichever typedef has the SEL type (although I can't currently find the correct place for doing this - hints welcome).

David