diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2011-06-01 09:30:18 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2011-06-01 09:30:18 +0000 |
commit | 98ab0248600687a1a0df95fa2eed84ed170c405e (patch) | |
tree | 67f5d2229b320cfa6954f818d7888459b3ef0993 /gcc/objc | |
parent | 6807da97b7a1d22a82a48844ccacfbdfcb983ada (diff) | |
download | gcc-98ab0248600687a1a0df95fa2eed84ed170c405e.zip gcc-98ab0248600687a1a0df95fa2eed84ed170c405e.tar.gz gcc-98ab0248600687a1a0df95fa2eed84ed170c405e.tar.bz2 |
In gcc/objc/: 2011-06-01 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/objc/:
2011-06-01 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_decl_method_attributes): Implement nonnull
attribute for Objective-C methods.
In gcc/testsuite/:
2011-06-01 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/attributes/method-nonnull-1.m: New test.
* obj-c++.dg/attributes/method-nonnull-1.mm: New test.
From-SVN: r174520
Diffstat (limited to 'gcc/objc')
-rw-r--r-- | gcc/objc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 42 |
2 files changed, 47 insertions, 0 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 0b8b595..c52fcc3 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,8 @@ +2011-06-01 Nicola Pero <nicola.pero@meta-innovation.com> + + * objc-act.c (objc_decl_method_attributes): Implement nonnull + attribute for Objective-C methods. + 2011-05-21 Nicola Pero <nicola.pero@meta-innovation.com> * config-lang.in (gtfiles): Updated order of files to fix building diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 0e15fe5..be65a53 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -5042,6 +5042,48 @@ objc_decl_method_attributes (tree *node, tree attributes, int flags) filtered_attributes = chainon (filtered_attributes, new_attribute); } + else if (is_attribute_p ("nonnull", name)) + { + /* We need to fixup all the argument indexes by adding 2 + for the two hidden arguments of an Objective-C method + invocation, similat to what we do above for the + "format" attribute. */ + /* FIXME: This works great in terms of implementing the + functionality, but the warnings that are produced by + nonnull do mention the argument index (while the + format ones don't). For example, you could get + "warning: null argument where non-null required + (argument 3)". Now in that message, "argument 3" + includes the 2 hidden arguments; it would be much + more friendly to call it "argument 1", as that would + be consistent with __attribute__ ((nonnnull (1))). + To do this, we'd need to have the C family code that + checks the arguments know about adding/removing 2 to + the argument index ... or alternatively we could + maybe store the "printable" argument index in + addition to the actual argument index ? Some + refactoring is needed to do this elegantly. */ + tree new_attribute = copy_node (attribute); + tree argument = TREE_VALUE (attribute); + while (argument != NULL_TREE) + { + /* Get the value of the argument and add 2. */ + tree number = TREE_VALUE (argument); + if (number + && TREE_CODE (number) == INTEGER_CST + && TREE_INT_CST_HIGH (number) == 0 + && TREE_INT_CST_LOW (number) != 0) + { + TREE_VALUE (argument) + = build_int_cst (integer_type_node, + TREE_INT_CST_LOW (number) + 2); + } + argument = TREE_CHAIN (argument); + } + + filtered_attributes = chainon (filtered_attributes, + new_attribute); + } else warning (OPT_Wattributes, "%qE attribute directive ignored", name); } |