diff options
author | Iain Sandoe <iains@gcc.gnu.org> | 2010-11-06 10:48:18 +0000 |
---|---|---|
committer | Iain Sandoe <iains@gcc.gnu.org> | 2010-11-06 10:48:18 +0000 |
commit | 91ebb981ec251976ec43c36e7f2de101855d2b45 (patch) | |
tree | af63074e9f4040f49a64cedb2d17c074c3c9f236 /gcc/objc/objc-act.c | |
parent | 2952a37e88596fa92a77bb8ae9c7afac7e727d46 (diff) | |
download | gcc-91ebb981ec251976ec43c36e7f2de101855d2b45.zip gcc-91ebb981ec251976ec43c36e7f2de101855d2b45.tar.gz gcc-91ebb981ec251976ec43c36e7f2de101855d2b45.tar.bz2 |
NS/CF String format syntax parsing.
gcc:
PR target/44981
* doc/extend.tex (format): Document NSString extension.
(format_arg): Likewise.
(Darwin Format Checks): New section.
* doc/tm.texi: Document string object hooks (generated).
* doc/tm.texi.in (TARGET_OBJC_CONSTRUCT_STRING_OBJECT) Rename.
(TARGET_STRING_OBJECT_REF_TYPE_P): New.
(TARGET_CHECK_STRING_OBJECT_FORMAT_ARG): New.
* target.def (objc_construct_string_object): Rename, amend
documentation.
(string_object_ref_type_p): New hook.
(check_string_object_format_arg): New hook.
* c-parser.c (c_parser_attributes): Allow objective-c class names as
attribute identifiers.
* config/darwin-c.c (darwin_cfstring_ref_p): New.
(darwin_check_cfstring_format_arg): New.
(darwin_additional_format_types): New.
* config/darwin-protos.h (darwin_cfstring_ref_p) New.
(darwin_check_cfstring_format_arg): New.
* config/darwin.h (TARGET_OBJC_CONSTRUCT_STRING_OBJECT) Renamed.
(TARGET_STRING_OBJECT_REF_TYPE_P): New.
(TARGET_N_FORMAT_TYPES): New.
(TARGET_CHECK_STRING_OBJECT_FORMAT_ARG): New.
gcc/c-family:
PR target/44981
* c-format.c (format_type): New type gcc_objc_string_format_type.
(valid_stringptr_type_p): New.
(handle_format_arg_attribute): Use valid_stringptr_type_p ().
(check_format_string): Pass expected type, use
valid_stringptr_type_p (), check that the format string types are
consistent with the format specification.
(decode_format_attr): Warn if NSString is used outside objective-c.
(format_types_orig): Add NSString.
(format_name): New.
(format_flags): New.
(check_format_arg): Handle format strings requiring an external parser.
first_target_format_type: New variable.
(handle_format_attribute): Set up first_target_format_type, pass the
expected format arg string type to check_format_string().
* c-common.h (FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL): New flag.
* stub-objc.c (objc_string_ref_type_p): New.
(objc_check_format_arg): New.
gcc/objc:
PR target/44981
* objc-act.c (objc_build_string_object): Amend for renamed hook.
(objc_string_ref_type_p): New.
(objc_check_format_arg): New.
gcc/testsuite:
PR target/44981
* gcc.dg/darwin-cfstring-format-1.c: New.
* gcc.dg/warn-nsstring.c: New.
* objc.dg/fsf-nsstring-format-1.m: New.
* obj-c++.dg/fsf-nsstring-format-1.mm: New.
* obj-c++.dg/torture/strings/const-cfstring-1.mm: Update for darwin10
linker warning.
From-SVN: r166398
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r-- | gcc/objc/objc-act.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index aa4c2e3..02966a8 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-common.h" #include "c-family/c-pragma.h" +#include "c-family/c-format.h" #include "flags.h" #include "langhooks.h" #include "objc-act.h" @@ -2755,9 +2756,9 @@ objc_build_string_object (tree string) literal. On Darwin (Mac OS X), for example, we may wish to obtain a constant CFString reference instead. At present, this is only supported for the NeXT runtime. */ - if (flag_next_runtime && targetcm.objc_construct_string) + if (flag_next_runtime && targetcm.objc_construct_string_object) { - tree constructor = (*targetcm.objc_construct_string) (string); + tree constructor = (*targetcm.objc_construct_string_object) (string); if (constructor) return build1 (NOP_EXPR, objc_object_type, constructor); } @@ -12673,4 +12674,28 @@ objc_finish_foreach_loop (location_t location, tree object_expression, tree coll /* Done by c-parser.c */ } +/* Return true if we have an NxString object pointer. */ + +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 + && TREE_CODE (tmv) == IDENTIFIER_NODE + && IDENTIFIER_POINTER (tmv) + && !strncmp (IDENTIFIER_POINTER (tmv), "NSString", 8)); +} + +/* At present the behavior of this is undefined and it does nothing. */ +void +objc_check_format_arg (tree ARG_UNUSED (format_arg), + tree ARG_UNUSED (args_list)) +{ +} + #include "gt-objc-objc-act.h" |