diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-12-28 12:39:29 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-12-28 12:39:29 +0000 |
commit | 35bce82a804f8637741ebb6fac3fe452131c987d (patch) | |
tree | 06c6eb826aebfbc42cbcde31960ccc798313f917 /gcc/objc/objc-act.c | |
parent | ecd815ac6be681098717d1347df7d670ee167337 (diff) | |
download | gcc-35bce82a804f8637741ebb6fac3fe452131c987d.zip gcc-35bce82a804f8637741ebb6fac3fe452131c987d.tar.gz gcc-35bce82a804f8637741ebb6fac3fe452131c987d.tar.bz2 |
In gcc/objc/: 2010-12-28 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/objc/:
2010-12-28 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_start_category_interface): Produce an error if
a class extension is found after the class @implementation.
In gcc/testsuite/:
2010-12-28 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/class-extension-4.m: New.
* obj-c++.dg/class-extension-4.mm: New.
From-SVN: r168294
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r-- | gcc/objc/objc-act.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index ba6c810..1117967 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -763,6 +763,23 @@ objc_start_category_interface (tree klass, tree categ, { if (flag_objc1_only) error_at (input_location, "class extensions are not available in Objective-C 1.0"); + else + { + /* Iterate over all the classes and categories implemented + up to now in this compilation unit. */ + struct imp_entry *t; + + for (t = imp_list; t; t = t->next) + { + /* If we find a class @implementation with the same name + as the one we are extending, produce an error. */ + if (TREE_CODE (t->imp_context) == CLASS_IMPLEMENTATION_TYPE + && IDENTIFIER_POINTER (CLASS_NAME (t->imp_context)) == IDENTIFIER_POINTER (klass)) + error_at (input_location, + "class extension for class %qE declared after its %<@implementation%>", + klass); + } + } } objc_interface_context = start_class (CATEGORY_INTERFACE_TYPE, klass, categ, protos, NULL_TREE); |