diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-11-04 20:59:47 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-11-04 20:59:47 +0000 |
commit | bede2adc26d83608df2c21d82d1ff0246baf1456 (patch) | |
tree | 2b4508d7ce478977e3fa9afe261f77ad36ad4f6d /gcc/objc/objc-act.c | |
parent | 2b78d0f15208ab3a0377d3ffac1a0325e202a95a (diff) | |
download | gcc-bede2adc26d83608df2c21d82d1ff0246baf1456.zip gcc-bede2adc26d83608df2c21d82d1ff0246baf1456.tar.gz gcc-bede2adc26d83608df2c21d82d1ff0246baf1456.tar.bz2 |
In gcc/: 2010-11-04 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/:
2010-11-04 Nicola Pero <nicola.pero@meta-innovation.com>
Fixed using the Objective-C 2.0 dot-syntax with class names.
* c-parser.c (c_parser_next_token_starts_declspecs): In
Objective-C, detect Objective-C 2.0 dot-syntax with a class name.
(c_parser_next_token_starts_declaration): Same.
(c_parser_postfix_expression): Parse the Objective-C 2.0
dot-syntax with a class name.
In gcc/cp/:
2010-11-04 Nicola Pero <nicola.pero@meta-innovation.com>
Fixed using the Objective-C 2.0 dot-syntax with class names.
* parser.c (cp_parser_primary_expression): Recognize Objective-C
2.0 dot-syntax with class names and process it.
(cp_parser_nonclass_name): Recognize Objective-C 2.0 dot-syntax
with class names.
(cp_parser_class_name): Same change.
(cp_parser_simple_type_specifier): Tidied comments.
In gcc/c-family/:
2010-11-04 Nicola Pero <nicola.pero@meta-innovation.com>
Fixed using the Objective-C 2.0 dot-syntax with class names.
* c-common.h (objc_build_class_component_ref): New.
* stub-objc.c (objc_build_class_component_ref): New.
In gcc/objc/:
2010-11-04 Nicola Pero <nicola.pero@meta-innovation.com>
Fixed using the Objective-C 2.0 dot-syntax with class names.
* objc-act.c (objc_build_class_component_ref): New.
In gcc/testsuite/:
2010-11-04 Nicola Pero <nicola.pero@meta-innovation.com>
Fixed using the Objective-C 2.0 dot-syntax with class names.
* objc.dg/property/dotsyntax-3.m: New.
* objc.dg/property/dotsyntax-4.m: New.
* obj-c++.dg/property/dotsyntax-3.mm: New.
* obj-c++.dg/property/dotsyntax-4.mm: New.
* objc.dg/fobjc-std-1.m: Added test for warnings when the
Objective-C 2.0 dot-syntax is used with class names.
* obj-c++.dg/fobjc-std-1.mm: Same change.
From-SVN: r166333
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r-- | gcc/objc/objc-act.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 40ecc4c..aa4c2e3 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -1301,6 +1301,79 @@ objc_maybe_build_component_ref (tree object, tree property_ident) return NULL_TREE; } +/* This hook routine is invoked by the parser when an expression such + as 'xxx.yyy' is parsed, and 'xxx' is a class name. This is the + Objective-C 2.0 dot-syntax applied to classes, so we need to + convert it into a setter/getter call on the class. */ +tree +objc_build_class_component_ref (tree class_name, tree property_ident) +{ + tree x = NULL_TREE; + tree object, rtype; + + if (flag_objc1_only) + error_at (input_location, "the dot syntax is not available in Objective-C 1.0"); + + if (class_name == NULL_TREE || class_name == error_mark_node + || TREE_CODE (class_name) != IDENTIFIER_NODE) + return error_mark_node; + + if (property_ident == NULL_TREE || property_ident == error_mark_node + || TREE_CODE (property_ident) != IDENTIFIER_NODE) + return NULL_TREE; + + object = objc_get_class_reference (class_name); + if (!object) + { + /* We know that 'class_name' is an Objective-C class name as the + parser won't call this function if it is not. This is only a + double-check for safety. */ + error_at (input_location, "could not find class %qE", class_name); + return error_mark_node; + } + + rtype = lookup_interface (class_name); + if (!rtype) + { + /* Again, this should never happen, but we do check. */ + error_at (input_location, "could not find interface for class %qE", class_name); + return error_mark_node; + } + + x = maybe_make_artificial_property_decl (rtype, NULL_TREE, + property_ident, + true); + + if (x) + { + tree expression; + + if (TREE_DEPRECATED (x)) + warn_deprecated_use (x, NULL_TREE); + + expression = build2 (PROPERTY_REF, TREE_TYPE(x), object, x); + SET_EXPR_LOCATION (expression, input_location); + TREE_SIDE_EFFECTS (expression) = 1; + /* See above for why we do this. */ + if (!PROPERTY_HAS_NO_GETTER (x)) + objc_finish_message_expr (object, + PROPERTY_GETTER_NAME (x), + NULL_TREE); + + return expression; + } + else + { + error_at (input_location, "could not find setter/getter for %qE in class %qE", + property_ident, class_name); + return error_mark_node; + } + + return NULL_TREE; +} + + + /* This is used because we don't want to expose PROPERTY_REF to the C/C++ frontends. Maybe we should! */ bool |