Message ID | 3F894B1C-C5CE-45FD-B73F-843A2C7ED940@sandoe-acoustics.co.uk |
---|---|
State | New |
Headers | show |
On Sun, 24 Oct 2010, IainS wrote: > * c-family/c-format.c (format_type): Add gcc_objc_string_format_type. > (valid_stringptr_type_p): New. > (handle_format_arg_attribute): Use valid_stringptr_type_p(). > (check_format_string): Likewise. > (format_types_orig): Add NSString. > * c-family/c-common.h (objc_string_ref_type_p): New prototype. (c-family/ has its own ChangeLog.) Is there something missing here that will be in a followup patch? You're adding a new format style, "NSString". There's no documentation for what it means, no testcases for this format style checking, and the table entry appears to be a dummy table entry. What happens when the compiler tries to check a call to a function declared to use that type of format? Are all the NULL table entries safe or will it try to dereference them? Do these strings appear as STRING_CST? If not, where is the code that knows how to extract the characters from them for checking? > +/* Check that we have a pointer to a string, or string object for objc and > + targets that support them in c*. */ What does "targets that support them in c*" mean? You should explicitly state what the return value means, and what STRP is. > + || (*targetcm.string_object_ref_type_p) ((const_tree)strp))); Missing space in cast. > + if (! valid_stringptr_type_p (TREE_TYPE (type))) Excess space in unary !. > + if (! argument Likewise. > Index: gcc/config/darwin.c > =================================================================== > --- gcc/config/darwin.c (revision 165889) > +++ gcc/config/darwin.c (working copy) > @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see > #include "debug.h" > #include "obstack.h" > #include "lto-streamer.h" > +#include "c-family/c-format.h" There are a few legacy c-* includes in target .c files that aren't c-family-specific, but you shouldn't add to them in new patches; why can't this go in darwin-c.c?
Hello Joseph, Thanks for the quick review, On 24 Oct 2010, at 15:26, Joseph S. Myers wrote: > On Sun, 24 Oct 2010, IainS wrote: > >> * c-family/c-format.c (format_type): Add >> gcc_objc_string_format_type. >> (valid_stringptr_type_p): New. >> (handle_format_arg_attribute): Use valid_stringptr_type_p(). >> (check_format_string): Likewise. >> (format_types_orig): Add NSString. >> * c-family/c-common.h (objc_string_ref_type_p): New prototype. > > (c-family/ has its own ChangeLog.) sorry, brainstorm... too late at night when I wrote the changelog. > Is there something missing here that will be in a followup patch? I don't believe so. > You're adding a new format style, "NSString". There's no > documentation > for what it means, NSString is documented in the relevant Objective C documentation. - should I add a cross-reference here ? or simply state what it is? (it matches the enum format_type gcc_objc_string_format_type) > no testcases for this format style checking, the tests are already present (in test-cases that currently fail for NeXT ObjC). I can also make additional stand-alone ones as a follow-up if that is deemed worthwhile. > and the > table entry appears to be a dummy table entry. What happens when the > compiler tries to check a call to a function declared to use that > type of > format? Are all the NULL table entries safe I believe so - the purpose is simply to check consistency of definition - there is no attempt to look within the entities themselves. > or will it try to dereference them? IFAIU, it should not. > Do these strings appear as STRING_CST? no - the references are to an opaque type (which is what is being checked for in the code called from valid_stringptr_type_p()). > If not, where is the code > that knows how to extract the characters from them for checking? ObjC* code that would use such an NSString reference (or the c* code that would use a CFString reference) must know how to deal with the relevant class reference - there is no code to parse such a string within c-family/ (for example, it is _not_ intended that printf should be able to handle a NSString - and to try to do so would result in a parse error). >> +/* Check that we have a pointer to a string, or string object for >> objc and >> + targets that support them in c*. */ > > What does "targets that support them in c*" mean? You should > explicitly > state what the return value means, and what STRP is. > >> + || (*targetcm.string_object_ref_type_p) ((const_tree)strp))); > > Missing space in cast. > >> + if (! valid_stringptr_type_p (TREE_TYPE (type))) > > Excess space in unary !. > >> + if (! argument > > Likewise. all noted, thanks. > >> Index: gcc/config/darwin.c >> =================================================================== >> --- gcc/config/darwin.c (revision 165889) >> +++ gcc/config/darwin.c (working copy) >> @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see >> #include "debug.h" >> #include "obstack.h" >> #include "lto-streamer.h" >> +#include "c-family/c-format.h" > > There are a few legacy c-* includes in target .c files that aren't > c-family-specific, but you shouldn't add to them in new patches; why > can't > this go in darwin-c.c? OK, indeed that makes more sense, will do, Iain > > -- > Joseph S. Myers > joseph@codesourcery.com
On Sun, 24 Oct 2010, IainS wrote: > > You're adding a new format style, "NSString". There's no documentation > > for what it means, > > NSString is documented in the relevant Objective C documentation. > - should I add a cross-reference here ? > or simply state what it is? The Objective C documentation describes __attribute__((__format__(NSString,1,2))) or similar? > > no testcases for this format style checking, > > the tests are already present (in test-cases that currently fail for NeXT > ObjC). What testcases? Please give specific file names of tests in the GCC testsuite that FAIL before this patch, PASS afterwards, and use the sort of format attribute construct I mention above.
Hello Joseph, On 24 Oct 2010, at 16:27, Joseph S. Myers wrote: > On Sun, 24 Oct 2010, IainS wrote: > >>> You're adding a new format style, "NSString". There's no >>> documentation >>> for what it means, >> >> NSString is documented in the relevant Objective C documentation. >> - should I add a cross-reference here ? >> or simply state what it is? > > The Objective C documentation describes > __attribute__((__format__(NSString,1,2))) or similar? no, whilst it does discuss attribute markup, it does not give such a format example. I'll add something to the gcc doc. >>> no testcases for this format style checking, >> >> the tests are already present (in test-cases that currently fail >> for NeXT >> ObjC). > > What testcases? Please give specific file names of tests in the GCC > testsuite that FAIL before this patch, PASS afterwards, and use the > sort > of format attribute construct I mention above. on Darwin10, any test-case that includes <Foundation/Foundation.h> or anything that includes (indirectly usually) CFString.h for example; gcc/testsuite/objc.dg/no-extra-load.m:#import <Foundation/Foundation.h> gcc/testsuite/objc.dg/objc-foreach-4.m:#include <Foundation/ Foundation.h> gcc/testsuite/objc.dg/objc-foreach-5.m:#import <Foundation/Foundation.h> but, of course, I am happy to improve test coverage - I have one or two stand-alone tests in my local test directory that could be used. At present, this is all darwin-specific, although Nicola might wish to extend to GNUstep, the consensus was probably not during 4.6. I'll wait for any further comments, and for Mike's input and then update the patch. thanks. Iain > -- > Joseph S. Myers > joseph@codesourcery.com
On Sun, Oct 24, 2010 at 05:20:19PM +0100, IainS wrote: > > on Darwin10, any test-case that includes <Foundation/Foundation.h> > or anything that includes (indirectly usually) CFString.h > > for example; > gcc/testsuite/objc.dg/no-extra-load.m:#import <Foundation/Foundation.h> > gcc/testsuite/objc.dg/objc-foreach-4.m:#include <Foundation/ > Foundation.h> > gcc/testsuite/objc.dg/objc-foreach-5.m:#import <Foundation/Foundation.h> > Iain, I am finding on x86_64-apple-darwin10 that your patch eliminates the following testsuite failures... unix/-m32 FAIL: objc.dg/no-extra-load.m -fnext-runtime (test for excess errors) ERROR: objc.dg/no-extra-load.m: error executing dg-final: couldn't open "no-extra-load.s": no such file or directory UNRESOLVED: objc.dg/no-extra-load.m: error executing dg-final: couldn't open "no-extra-load.s": no such file or directory FAIL: objc.dg/objc-foreach-4.m -fnext-runtime (test for excess errors) FAIL: objc.dg/objc-foreach-5.m -fnext-runtime (test for excess errors) ERROR: objc.dg/objc-foreach-5.m: error executing dg-final: couldn't open "objc-foreach-5.s": no such file or directory UNRESOLVED: objc.dg/objc-foreach-5.m: error executing dg-final: couldn't open "objc-foreach-5.s": no such file or directory FAIL: objc.dg/property/property-2.m -fnext-runtime (test for excess errors) WARNING: objc.dg/property/property-2.m -fnext-runtime compilation failed to produce executable FAIL: objc.dg/property/property-3.m -fnext-runtime (test for excess errors) WARNING: objc.dg/property/property-3.m -fnext-runtime compilation failed to produce executable FAIL: objc.dg/torture/strings/const-cfstring-1.m -O0 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O1 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -fomit-frame-pointer -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -g -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -Os -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -flto -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fwhopr -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/property/property-2.mm -fnext-runtime (test for excess errors) WARNING: obj-c++.dg/property/property-2.mm -fnext-runtime compilation failed to produce executable FAIL: obj-c++.dg/property/property-3.mm -fnext-runtime (test for excess errors) WARNING: obj-c++.dg/property/property-3.mm -fnext-runtime compilation failed to produce executable FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O0 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O1 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -fomit-frame-pointer -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -g -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -Os -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -flto -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fwhopr -fnext-runtime (test for excess errors) unix/-m64 FAIL: objc.dg/no-extra-load.m -fnext-runtime (test for excess errors) ERROR: objc.dg/no-extra-load.m: error executing dg-final: couldn't open "no-extra-load.s": no such file or directory UNRESOLVED: objc.dg/no-extra-load.m: error executing dg-final: couldn't open "no-extra-load.s": no such file or directory FAIL: objc.dg/objc-foreach-4.m -fnext-runtime (test for excess errors) FAIL: objc.dg/objc-foreach-5.m -fnext-runtime (test for excess errors) ERROR: objc.dg/objc-foreach-5.m: error executing dg-final: couldn't open "objc-foreach-5.s": no such file or directory UNRESOLVED: objc.dg/objc-foreach-5.m: error executing dg-final: couldn't open "objc-foreach-5.s": no such file or directory FAIL: objc.dg/torture/strings/const-cfstring-1.m -O0 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O1 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -fomit-frame-pointer -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -g -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -Os -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -flto -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fwhopr -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O0 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O1 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -fomit-frame-pointer -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -g -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -Os -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -flto -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fwhopr -fnext-runtime (test for excess errors)
Yes :-( whenever possible, ObjC/ObjC++ testcases shouldn't #import <Foundation/Foundation.h> ... * it destroys the whole point of having testcases test a single, specific part or feature of the compiler * whether testcases pass or not depend on the version of the FoundationKit being used * it is hard to run any such tests with the GNU runtime (Btw, ObjC/ObjC++ testcases that #import <Foundation/Foundation.h> usually come from Apple - we should really try to clean them to avoid Foundation/Foundation.h if possible) ;-) Thanks -----Original Message----- From: "Jack Howarth" <howarth@bromo.med.uc.edu> Sent: Sunday, 24 October, 2010 22:05 To: "IainS" <developer@sandoe-acoustics.co.uk> Cc: "Joseph S. Myers" <joseph@codesourcery.com>, "GCC Patches" <gcc-patches@gcc.gnu.org>, "Mike Stump" <mrs@gcc.gnu.org> Subject: Re: [Patch, c* ,ObjC*] handle string objects in format checking. On Sun, Oct 24, 2010 at 05:20:19PM +0100, IainS wrote: > > on Darwin10, any test-case that includes <Foundation/Foundation.h> > or anything that includes (indirectly usually) CFString.h > > for example; > gcc/testsuite/objc.dg/no-extra-load.m:#import <Foundation/Foundation.h> > gcc/testsuite/objc.dg/objc-foreach-4.m:#include <Foundation/ > Foundation.h> > gcc/testsuite/objc.dg/objc-foreach-5.m:#import <Foundation/Foundation.h> > Iain, I am finding on x86_64-apple-darwin10 that your patch eliminates the following testsuite failures... unix/-m32 FAIL: objc.dg/no-extra-load.m -fnext-runtime (test for excess errors) ERROR: objc.dg/no-extra-load.m: error executing dg-final: couldn't open "no-extra-load.s": no such file or directory UNRESOLVED: objc.dg/no-extra-load.m: error executing dg-final: couldn't open "no-extra-load.s": no such file or directory FAIL: objc.dg/objc-foreach-4.m -fnext-runtime (test for excess errors) FAIL: objc.dg/objc-foreach-5.m -fnext-runtime (test for excess errors) ERROR: objc.dg/objc-foreach-5.m: error executing dg-final: couldn't open "objc-foreach-5.s": no such file or directory UNRESOLVED: objc.dg/objc-foreach-5.m: error executing dg-final: couldn't open "objc-foreach-5.s": no such file or directory FAIL: objc.dg/property/property-2.m -fnext-runtime (test for excess errors) WARNING: objc.dg/property/property-2.m -fnext-runtime compilation failed to produce executable FAIL: objc.dg/property/property-3.m -fnext-runtime (test for excess errors) WARNING: objc.dg/property/property-3.m -fnext-runtime compilation failed to produce executable FAIL: objc.dg/torture/strings/const-cfstring-1.m -O0 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O1 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -fomit-frame-pointer -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -g -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -Os -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -flto -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fwhopr -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/property/property-2.mm -fnext-runtime (test for excess errors) WARNING: obj-c++.dg/property/property-2.mm -fnext-runtime compilation failed to produce executable FAIL: obj-c++.dg/property/property-3.mm -fnext-runtime (test for excess errors) WARNING: obj-c++.dg/property/property-3.mm -fnext-runtime compilation failed to produce executable FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O0 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O1 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -fomit-frame-pointer -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -g -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -Os -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -flto -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fwhopr -fnext-runtime (test for excess errors) unix/-m64 FAIL: objc.dg/no-extra-load.m -fnext-runtime (test for excess errors) ERROR: objc.dg/no-extra-load.m: error executing dg-final: couldn't open "no-extra-load.s": no such file or directory UNRESOLVED: objc.dg/no-extra-load.m: error executing dg-final: couldn't open "no-extra-load.s": no such file or directory FAIL: objc.dg/objc-foreach-4.m -fnext-runtime (test for excess errors) FAIL: objc.dg/objc-foreach-5.m -fnext-runtime (test for excess errors) ERROR: objc.dg/objc-foreach-5.m: error executing dg-final: couldn't open "objc-foreach-5.s": no such file or directory UNRESOLVED: objc.dg/objc-foreach-5.m: error executing dg-final: couldn't open "objc-foreach-5.s": no such file or directory FAIL: objc.dg/torture/strings/const-cfstring-1.m -O0 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O1 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -fomit-frame-pointer -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -g -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -Os -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -flto -fnext-runtime (test for excess errors) FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fwhopr -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O0 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O1 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -fomit-frame-pointer -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -g -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -Os -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -flto -fnext-runtime (test for excess errors) FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fwhopr -fnext-runtime (test for excess errors)
Hi Nicola, I agree in general terms, as much as possible should be independent - and I've been "gnu-ifying" the NeXT cases and "next-ifying" the gnu ones as much as possible. However, we need to test stuff that performs the required functions with the NeXT runtime (which might include functionality outside what we have implemented for gnu). -- being able to compile the Foundation (ObjC*) and CoreFoundation (c* and ObjC*) headers is pretty (possibly vitally) important for use of FSF gcc on Darwin. I'm working on making this particular change a little less obtuse. cheers, Iain On 24 Oct 2010, at 21:50, Nicola Pero wrote: > Yes :-( > > whenever possible, ObjC/ObjC++ testcases shouldn't #import > <Foundation/Foundation.h> ... > > * it destroys the whole point of having testcases test a single, > specific part or feature of the compiler > > * whether testcases pass or not depend on the version of the > FoundationKit being used > > * it is hard to run any such tests with the GNU runtime > > (Btw, ObjC/ObjC++ testcases that #import <Foundation/Foundation.h> > usually come from Apple - we > should really try to clean them to avoid Foundation/Foundation.h if > possible) ;-) > > Thanks > > -----Original Message----- > From: "Jack Howarth" <howarth@bromo.med.uc.edu> > Sent: Sunday, 24 October, 2010 22:05 > To: "IainS" <developer@sandoe-acoustics.co.uk> > Cc: "Joseph S. Myers" <joseph@codesourcery.com>, "GCC Patches" <gcc-patches@gcc.gnu.org > >, "Mike Stump" <mrs@gcc.gnu.org> > Subject: Re: [Patch, c* ,ObjC*] handle string objects in format > checking. > > On Sun, Oct 24, 2010 at 05:20:19PM +0100, IainS wrote: >> >> on Darwin10, any test-case that includes <Foundation/Foundation.h> >> or anything that includes (indirectly usually) CFString.h >> >> for example; >> gcc/testsuite/objc.dg/no-extra-load.m:#import <Foundation/ >> Foundation.h> >> gcc/testsuite/objc.dg/objc-foreach-4.m:#include <Foundation/ >> Foundation.h> >> gcc/testsuite/objc.dg/objc-foreach-5.m:#import <Foundation/ >> Foundation.h> >> > > Iain, > I am finding on x86_64-apple-darwin10 that your patch eliminates > the following > testsuite failures... > > unix/-m32 > FAIL: objc.dg/no-extra-load.m -fnext-runtime (test for excess errors) > ERROR: objc.dg/no-extra-load.m: error executing dg-final: couldn't > open "no-extra-load.s": no such file or directory > UNRESOLVED: objc.dg/no-extra-load.m: error executing dg-final: > couldn't open "no-extra-load.s": no such file or directory > FAIL: objc.dg/objc-foreach-4.m -fnext-runtime (test for excess errors) > FAIL: objc.dg/objc-foreach-5.m -fnext-runtime (test for excess errors) > ERROR: objc.dg/objc-foreach-5.m: error executing dg-final: couldn't > open "objc-foreach-5.s": no such file or directory > UNRESOLVED: objc.dg/objc-foreach-5.m: error executing dg-final: > couldn't open "objc-foreach-5.s": no such file or directory > FAIL: objc.dg/property/property-2.m -fnext-runtime (test for excess > errors) > WARNING: objc.dg/property/property-2.m -fnext-runtime compilation > failed to produce executable > FAIL: objc.dg/property/property-3.m -fnext-runtime (test for excess > errors) > WARNING: objc.dg/property/property-3.m -fnext-runtime compilation > failed to produce executable > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O0 -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O1 -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -fomit-frame- > pointer -fnext-runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -g -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -Os -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -flto -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fwhopr - > fnext-runtime (test for excess errors) > FAIL: obj-c++.dg/property/property-2.mm -fnext-runtime (test for > excess errors) > WARNING: obj-c++.dg/property/property-2.mm -fnext-runtime > compilation failed to produce executable > FAIL: obj-c++.dg/property/property-3.mm -fnext-runtime (test for > excess errors) > WARNING: obj-c++.dg/property/property-3.mm -fnext-runtime > compilation failed to produce executable > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O0 -fnext- > runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O1 -fnext- > runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fnext- > runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -fomit- > frame-pointer -fnext-runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -g -fnext- > runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -Os -fnext- > runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -flto - > fnext-runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fwhopr - > fnext-runtime (test for excess errors) > > unix/-m64 > FAIL: objc.dg/no-extra-load.m -fnext-runtime (test for excess errors) > ERROR: objc.dg/no-extra-load.m: error executing dg-final: couldn't > open "no-extra-load.s": no such file or directory > UNRESOLVED: objc.dg/no-extra-load.m: error executing dg-final: > couldn't open "no-extra-load.s": no such file or directory > FAIL: objc.dg/objc-foreach-4.m -fnext-runtime (test for excess errors) > FAIL: objc.dg/objc-foreach-5.m -fnext-runtime (test for excess errors) > ERROR: objc.dg/objc-foreach-5.m: error executing dg-final: couldn't > open "objc-foreach-5.s": no such file or directory > UNRESOLVED: objc.dg/objc-foreach-5.m: error executing dg-final: > couldn't open "objc-foreach-5.s": no such file or directory > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O0 -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O1 -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -fomit-frame- > pointer -fnext-runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O3 -g -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -Os -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -flto -fnext- > runtime (test for excess errors) > FAIL: objc.dg/torture/strings/const-cfstring-1.m -O2 -fwhopr - > fnext-runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O0 -fnext- > runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O1 -fnext- > runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fnext- > runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -fomit- > frame-pointer -fnext-runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O3 -g -fnext- > runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -Os -fnext- > runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -flto - > fnext-runtime (test for excess errors) > FAIL: obj-c++.dg/torture/strings/const-cfstring-1.mm -O2 -fwhopr - > fnext-runtime (test for excess errors) > > > > > >
On Oct 24, 2010, at 9:20 AM, IainS wrote:
> I'll wait for any further comments, and for Mike's input and then update the patch.
Usually we just update as we go... Once the issues Joseph pointed out are fixed, I'm fine with this.
Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi (revision 165889) +++ gcc/doc/tm.texi (working copy) @@ -746,6 +746,10 @@ should use @code{TARGET_HANDLE_C_OPTION} instead. Construct a constant string representation for @var{string} @end deftypefn +@deftypefn {Target Hook} bool TARGET_STRING_OBJECT_REF_TYPE_P (const_tree @var{stringref}) +Check for a valid string object reference type in @var{stringref} +@end deftypefn + @defmac TARGET_VERSION This macro is a C statement to print on @code{stderr} a string describing the particular machine description choice. Every machine Index: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in (revision 165889) +++ gcc/doc/tm.texi.in (working copy) @@ -744,6 +744,8 @@ should use @code{TARGET_HANDLE_C_OPTION} instead. @hook TARGET_OBJC_CONSTRUCT_STRING +@hook TARGET_STRING_OBJECT_REF_TYPE_P + @defmac TARGET_VERSION This macro is a C statement to print on @code{stderr} a string describing the particular machine description choice. Every machine Index: gcc/c-family/c-format.c =================================================================== --- gcc/c-family/c-format.c (revision 165889) +++ gcc/c-family/c-format.c (working copy) @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "c-format.h" #include "alloc-pool.h" +#include "target.h" /* Set format warning options according to a -Wformat=n option. */ @@ -63,6 +64,7 @@ enum format_type { printf_format_type, asm_fprintf gcc_diag_format_type, gcc_tdiag_format_type, gcc_cdiag_format_type, gcc_cxxdiag_format_type, gcc_gfc_format_type, + gcc_objc_string_format_type, format_type_error = -1}; typedef struct function_format_info @@ -83,6 +85,19 @@ static bool get_constant (tree expr, unsigned HOST static const char *convert_format_name_to_system_name (const char *attr_name); static bool cmp_attribs (const char *tattr_name, const char *attr_name); +/* Check that we have a pointer to a string, or string object for objc and + targets that support them in c*. */ + +static bool +valid_stringptr_type_p (tree strp) +{ + return (strp != NULL + && TREE_CODE (strp) == POINTER_TYPE + && (TYPE_MAIN_VARIANT (TREE_TYPE (strp)) == char_type_node + || objc_string_ref_type_p (strp) + || (*targetcm.string_object_ref_type_p) ((const_tree)strp))); +} + /* Handle a "format_arg" attribute; arguments as in struct attribute_spec.handler. */ tree @@ -108,9 +123,7 @@ handle_format_arg_attribute (tree *node, tree ARG_ return NULL_TREE; } - if (TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE - || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))) - != char_type_node)) + if (! valid_stringptr_type_p (TREE_TYPE (type))) { if (!(flags & (int) ATTR_FLAG_BUILT_IN)) error ("function does not return string type"); @@ -136,10 +149,8 @@ check_format_string (tree argument, unsigned HOST_ argument = TREE_CHAIN (argument); } - if (!argument - || TREE_CODE (TREE_VALUE (argument)) != POINTER_TYPE - || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (argument))) - != char_type_node)) + if (! argument + || !valid_stringptr_type_p (TREE_VALUE (argument))) { if (!(flags & (int) ATTR_FLAG_BUILT_IN)) error ("format string argument not a string type"); @@ -750,6 +761,11 @@ static const format_kind_info format_types_orig[] 0, 0, 0, 0, 0, 0, NULL, NULL }, + { "NSString", NULL, NULL, NULL, NULL, + NULL, NULL, + FMT_FLAG_ARG_CONVERT, 0, 0, 0, 0, 0, 0, + NULL, NULL + }, { "gnu_scanf", scanf_length_specs, scan_char_table, "*'I", NULL, scanf_flag_specs, scanf_flag_pairs, FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK, Index: gcc/c-family/c-common.h =================================================================== --- gcc/c-family/c-common.h (revision 165889) +++ gcc/c-family/c-common.h (working copy) @@ -1049,6 +1049,7 @@ extern tree objc_build_setter_call (tree, tree); extern void objc_add_synthesize_declaration (location_t, tree); extern void objc_add_dynamic_declaration (location_t, tree); extern const char * objc_maybe_printable_name (tree, int); +extern bool objc_string_ref_type_p (tree); /* The following are provided by the C and C++ front-ends, and called by ObjC/ObjC++. */ Index: gcc/c-family/stub-objc.c =================================================================== --- gcc/c-family/stub-objc.c (revision 165889) +++ gcc/c-family/stub-objc.c (working copy) @@ -426,3 +426,9 @@ void objc_write_global_declarations (void) { } + +bool +objc_string_ref_type_p (tree ARG_UNUSED (strp)) +{ + return false; +} Index: gcc/config/darwin-c.c =================================================================== --- gcc/config/darwin-c.c (revision 165889) +++ gcc/config/darwin-c.c (working copy) @@ -678,3 +678,21 @@ darwin_objc_construct_string (tree str) return darwin_build_constant_cfstring (str); } + +/* The string ref type is created as CFStringRef by <CFBase.h> therefore, we + must match for it explicitly, since it's outside the gcc code. */ + +bool +darwin_cfstring_ref_p (const_tree strp) +{ + tree tn; + if (!strp || TREE_CODE (strp) != POINTER_TYPE) + return false; + + tn = TYPE_NAME (strp); + if (tn) + tn = DECL_NAME (tn); + return (tn + && IDENTIFIER_POINTER (tn) + && !strncmp (IDENTIFIER_POINTER (tn), "CFStringRef", 8)); +} Index: gcc/config/darwin-protos.h =================================================================== --- gcc/config/darwin-protos.h (revision 165889) +++ gcc/config/darwin-protos.h (working copy) @@ -96,7 +96,8 @@ extern void darwin_init_cfstring_builtins (unsigne extern tree darwin_fold_builtin (tree, int, tree *, bool); extern tree darwin_objc_construct_string (tree); extern bool darwin_cfstring_p (tree); -extern tree darwin_build_constant_cfstring (tree str); +extern bool darwin_cfstring_ref_p (const_tree); +extern tree darwin_build_constant_cfstring (tree); extern void darwin_enter_string_into_cfstring_table (tree); extern void darwin_asm_output_anchor (rtx symbol); Index: gcc/config/darwin.c =================================================================== --- gcc/config/darwin.c (revision 165889) +++ gcc/config/darwin.c (working copy) @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "debug.h" #include "obstack.h" #include "lto-streamer.h" +#include "c-family/c-format.h" /* Darwin supports a feature called fix-and-continue, which is used for rapid turn around debugging. When code is compiled with the @@ -2269,4 +2270,13 @@ darwin_enter_string_into_cfstring_table (tree str) } } +/* The extra format types we recognize. */ +const format_kind_info darwin_additional_format_types[] = { + { "CFString", NULL, NULL, NULL, NULL, + NULL, NULL, + FMT_FLAG_ARG_CONVERT, 0, 0, 0, 0, 0, 0, + NULL, NULL + } +}; + #include "gt-darwin.h" Index: gcc/config/darwin.h =================================================================== --- gcc/config/darwin.h (revision 165889) +++ gcc/config/darwin.h (working copy) @@ -1060,6 +1060,12 @@ __enable_execute_stack (void *addr) #define TARGET_OBJC_CONSTRUCT_STRING \ darwin_objc_construct_string +#define TARGET_STRING_OBJECT_REF_TYPE_P \ + darwin_cfstring_ref_p + +#define TARGET_N_FORMAT_TYPES 1 +#define TARGET_FORMAT_TYPES darwin_additional_format_types + #define TARGET_HAS_TARGETCM 1 #ifndef CROSS_DIRECTORY_STRUCTURE Index: gcc/objc/objc-act.c =================================================================== --- gcc/objc/objc-act.c (revision 165889) +++ gcc/objc/objc-act.c (working copy) @@ -11801,4 +11801,21 @@ objc_finish_foreach_loop (location_t location, tre /* Done by c-parser.c */ } +/* Return true if we have an NxString object pointer. + Implemented only for NSString Objects so far. */ + +bool +objc_string_ref_type_p (tree strp) +{ + tree tmv; + if (!strp || TREE_CODE (strp) != POINTER_TYPE) + return false; + + tmv = TYPE_MAIN_VARIANT (TREE_TYPE (strp)); + tmv = OBJC_TYPE_NAME (tmv); + return (tmv + && IDENTIFIER_POINTER (tmv) + && !strncmp (IDENTIFIER_POINTER (tmv), "NSString", 8)); +} + #include "gt-objc-objc-act.h" Index: gcc/target.def =================================================================== --- gcc/target.def (revision 165889) +++ gcc/target.def (working copy) @@ -2539,5 +2539,11 @@ DEFHOOK "Construct a constant string representation for @var{string}", tree, (tree string), NULL) - + +DEFHOOK +(string_object_ref_type_p, + "Check for a valid string object reference type in @var{stringref}", + bool, (const_tree stringref), + hook_bool_const_tree_false) + HOOK_VECTOR_END (C90_EMPTY_HACK) Index: gcc/testsuite/obj-c++.dg/property/property-2.mm =================================================================== --- gcc/testsuite/obj-c++.dg/property/property-2.mm (revision 165889) +++ gcc/testsuite/obj-c++.dg/property/property-2.mm (working copy) @@ -5,6 +5,9 @@ /* { dg-require-effective-target ilp32 } */ /* Force ABI = 0 in the NeXT headers, also suppress deprecation warnings. */ /* { dg-options "-framework Foundation -fobjc-exceptions -mmacosx-version-min=10.4 -Wno-deprecated-declarations" } */ +/* Darwin10's linker emits a warning that the constant strings are incompatible with writable ones. + well, we don't implement writeable ones at this juncture. */ +/* { dg-options "-framework Foundation -fobjc-exceptions -mmacosx-version-min=10.4 -Wno-deprecated-declarations -Wl,-w" { target *-*-darwin[123]* } } */ #include <objc/objc-api.h> #include <Foundation/Foundation.h> Index: gcc/testsuite/obj-c++.dg/property/property-3.mm =================================================================== --- gcc/testsuite/obj-c++.dg/property/property-3.mm (revision 165889) +++ gcc/testsuite/obj-c++.dg/property/property-3.mm (working copy) @@ -6,6 +6,9 @@ /* { dg-require-effective-target ilp32 } */ /* Force ABI = 0 in the NeXT headers, also suppress deprecation warnings. */ /* { dg-options "-framework Foundation -fobjc-exceptions -mmacosx-version-min=10.4 -Wno-deprecated-declarations" } */ +/* Darwin10's linker emits a warning that the constant strings are incompatible with writable ones. + well, we don't implement writeable ones at this juncture. */ +/* { dg-options "-framework Foundation -fobjc-exceptions -mmacosx-version-min=10.4 -Wno-deprecated-declarations -Wl,-w" { target *-*-darwin[123]* } } */ #include <objc/objc-api.h> #include <Foundation/Foundation.h> Index: gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm =================================================================== --- gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm (revision 165889) +++ gcc/testsuite/obj-c++.dg/torture/strings/const-cfstring-1.mm (working copy) @@ -9,6 +9,9 @@ /* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ /* { dg-options "-mconstant-cfstrings -framework Cocoa" } */ +/* Darwin10's linker emits a warning that the constant strings are incompatible with writable ones. + well, we don't implement writable ones at this juncture. */ +/* { dg-options "-mconstant-cfstrings -framework Cocoa -Wl,-w" { target *-*-darwin[123]* } } */ #import <Foundation/NSString.h> #import <CoreFoundation/CFString.h> Index: gcc/testsuite/objc.dg/property/property-3.m =================================================================== --- gcc/testsuite/objc.dg/property/property-3.m (revision 165889) +++ gcc/testsuite/objc.dg/property/property-3.m (working copy) @@ -6,6 +6,9 @@ /* { dg-require-effective-target ilp32 } */ /* Force ABI = 0 in the NeXT headers, also suppress deprecation warnings. */ /* { dg-options "-framework Foundation -fobjc-exceptions -mmacosx-version-min=10.4 -Wno-deprecated-declarations" } */ +/* Darwin10's linker emits a warning that the constant strings are incompatible with writable ones. + well, we don't implement writeable ones at this juncture. */ +/* { dg-options "-framework Foundation -fobjc-exceptions -mmacosx-version-min=10.4 -Wno-deprecated-declarations -Wl,-w" { target *-*-darwin[123]* } } */ #include <objc/objc-api.h> #include <Foundation/Foundation.h> Index: gcc/testsuite/objc.dg/property/property-2.m =================================================================== --- gcc/testsuite/objc.dg/property/property-2.m (revision 165889) +++ gcc/testsuite/objc.dg/property/property-2.m (working copy) @@ -6,6 +6,9 @@ /* { dg-require-effective-target ilp32 } */ /* Force ABI = 0 in the NeXT headers, also suppress deprecation warnings. */ /* { dg-options "-framework Foundation -fobjc-exceptions -mmacosx-version-min=10.4 -Wno-deprecated-declarations" } */ +/* Darwin10's linker emits a warning that the constant strings are incompatible with writable ones. + well, we don't implement writeable ones at this juncture. */ +/* { dg-options "-framework Foundation -fobjc-exceptions -mmacosx-version-min=10.4 -Wno-deprecated-declarations -Wl,-w" { target *-*-darwin[123]* } } */ #include <objc/objc-api.h> #include <Foundation/Foundation.h> Index: gcc/testsuite/objc.dg/torture/strings/const-cfstring-1.m =================================================================== --- gcc/testsuite/objc.dg/torture/strings/const-cfstring-1.m (revision 165889) +++ gcc/testsuite/objc.dg/torture/strings/const-cfstring-1.m (working copy) @@ -9,6 +9,9 @@ /* { dg-skip-if "NeXT only" { *-*-* } { "-fgnu-runtime" } { "" } } */ /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ /* { dg-options "-mconstant-cfstrings -framework Cocoa" } */ +/* Darwin10's linker emits a warning that the constant strings are incompatible with writable ones. + well, we don't implement writable ones at this juncture. */ +/* { dg-options "-mconstant-cfstrings -framework Cocoa -Wl,-w" { target *-*-darwin[123]* } } */ #import <Foundation/NSString.h> #import <CoreFoundation/CFString.h>