In gcc/objc/: 2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com>
authorNicola Pero <nicola.pero@meta-innovation.com>
Mon, 29 Nov 2010 20:43:35 +0000 (20:43 +0000)
committerNicola Pero <nicola@gcc.gnu.org>
Mon, 29 Nov 2010 20:43:35 +0000 (20:43 +0000)
In gcc/objc/:
2010-11-29  Nicola Pero  <nicola.pero@meta-innovation.com>

* objc-act.c (objc_maybe_build_component_ref): Removed TODO.

In gcc/testsuite/:
2010-11-29  Nicola Pero  <nicola.pero@meta-innovation.com>

* objc.dg/property/dotsyntax-21.m
* obj-c++.dg/property/dotsyntax-21.mm

From-SVN: r167269

gcc/objc/ChangeLog
gcc/objc/objc-act.c
gcc/testsuite/ChangeLog
gcc/testsuite/obj-c++.dg/property/dotsyntax-21.mm [new file with mode: 0644]
gcc/testsuite/objc.dg/property/dotsyntax-21.m [new file with mode: 0644]

index 644129bbc1637b3440dfd0f9a7a77235f3633d28..636bf85de1bfe3a6f5e539d3d454cca9d70a13ac 100644 (file)
@@ -1,3 +1,7 @@
+2010-11-29  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc-act.c (objc_maybe_build_component_ref): Removed TODO.
+
 2010-11-29  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * objc-act.c (objc_eh_runtime_type): Avoid ICE if error_mark_node
index 810a53af95324a25d3e58109618ea761c66c179a..2382da4fd4d4eae3508e7f5b1889e0c004a8afe2 100644 (file)
@@ -1539,11 +1539,8 @@ objc_maybe_build_component_ref (tree object, tree property_ident)
                 || TREE_CODE (t) == COMPONENT_REF)
            t = TREE_OPERAND (t, 0);
          
-         if (t == UOBJC_SUPER_decl)
-           {
-             /* TODO: Check if this is correct also for 'super' in categories.  */
-             interface_type = lookup_interface (CLASS_SUPER_NAME (implementation_template));
-           }
+         if (t == UOBJC_SUPER_decl)    
+           interface_type = lookup_interface (CLASS_SUPER_NAME (implementation_template));
          else if (t == self_decl)
            interface_type = lookup_interface (CLASS_NAME (implementation_template));
 
index cfa16d3e2e6b5456227aa0107621eca308e00063..0a154e003a5388cd2e49169a021362975ae82793 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-29  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc.dg/property/dotsyntax-21.m
+       * obj-c++.dg/property/dotsyntax-21.mm
+
 2010-11-29  Alexandre Oliva  <aoliva@redhat.com>
 
        PR debug/46338
diff --git a/gcc/testsuite/obj-c++.dg/property/dotsyntax-21.mm b/gcc/testsuite/obj-c++.dg/property/dotsyntax-21.mm
new file mode 100644 (file)
index 0000000..4b8945e
--- /dev/null
@@ -0,0 +1,113 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
+/* { dg-do run } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+
+/* Test dot-syntax with super in a category.  */
+
+#include <stdlib.h>
+#include <objc/objc.h>
+#include <objc/runtime.h>
+
+@interface MyRootClass
+{
+  Class isa;
+  int a;
+}
++ (id) initialize;
++ (id) alloc;
+- (id) init;
+- (int) count;
+- (void) setCount: (int)count;
+@end
+
+@implementation MyRootClass
++ (id) initialize { return self; }
++ (id) alloc { return class_createInstance (self, 0); }
+- (id) init { return self; }
+- (int) count
+{
+  return a;
+}
+- (void) setCount: (int)count
+{
+  a = count;
+}
+@end
+
+/* First, test 'super' in the main implementation of a subclass.  */
+@interface MySubClass : MyRootClass
+- (int) superCount;
+- (void) setSuperCount: (int)count;
+@end
+
+@implementation MySubClass
+- (int) superCount
+{
+  return super.count;
+}
+- (void) setSuperCount: (int)count
+{
+  super.count = count;
+}
+@end
+
+/* Now, test 'super' in a category of a subclass.  */
+@interface MySubClass (Category)
+- (int) superCount2;
+- (void) setSuperCount2: (int)count;
+- (int) test: (int)x;
+@end
+
+@implementation MySubClass (Category)
+- (int) superCount2
+{
+  return super.count;
+}
+- (void) setSuperCount2: (int)count
+{
+  super.count = count;
+}
+- (int) test: (int)x
+{
+  /* For positive x, the following will leave super.count
+     unchanged.  */
+  super.count++;
+  --super.count;
+
+  super.count = (x < 0 ? x : super.count);
+  
+  if ((x = super.count))
+    super.count += 1;
+
+  if ((x = super.count))
+    super.count -= 1;
+
+  /* Finally, also put a bit of self.count in the mix.  */
+  self.count++;
+  super.count--;
+
+  return super.count;
+}
+@end
+
+int main (void)
+{
+  MySubClass *object = [[MySubClass alloc] init];
+
+  object.count = 10;
+  if (object.count != 10)
+    abort ();
+
+  object.superCount = 11;
+  if (object.superCount != 11)
+    abort ();
+
+  object.superCount2 = 12;
+  if (object.superCount2 != 12)
+    abort ();
+
+  if ([object test: 45] != 12)
+    abort ();
+
+  return 0;
+}
diff --git a/gcc/testsuite/objc.dg/property/dotsyntax-21.m b/gcc/testsuite/objc.dg/property/dotsyntax-21.m
new file mode 100644 (file)
index 0000000..4b8945e
--- /dev/null
@@ -0,0 +1,113 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
+/* { dg-do run } */
+/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+
+/* Test dot-syntax with super in a category.  */
+
+#include <stdlib.h>
+#include <objc/objc.h>
+#include <objc/runtime.h>
+
+@interface MyRootClass
+{
+  Class isa;
+  int a;
+}
++ (id) initialize;
++ (id) alloc;
+- (id) init;
+- (int) count;
+- (void) setCount: (int)count;
+@end
+
+@implementation MyRootClass
++ (id) initialize { return self; }
++ (id) alloc { return class_createInstance (self, 0); }
+- (id) init { return self; }
+- (int) count
+{
+  return a;
+}
+- (void) setCount: (int)count
+{
+  a = count;
+}
+@end
+
+/* First, test 'super' in the main implementation of a subclass.  */
+@interface MySubClass : MyRootClass
+- (int) superCount;
+- (void) setSuperCount: (int)count;
+@end
+
+@implementation MySubClass
+- (int) superCount
+{
+  return super.count;
+}
+- (void) setSuperCount: (int)count
+{
+  super.count = count;
+}
+@end
+
+/* Now, test 'super' in a category of a subclass.  */
+@interface MySubClass (Category)
+- (int) superCount2;
+- (void) setSuperCount2: (int)count;
+- (int) test: (int)x;
+@end
+
+@implementation MySubClass (Category)
+- (int) superCount2
+{
+  return super.count;
+}
+- (void) setSuperCount2: (int)count
+{
+  super.count = count;
+}
+- (int) test: (int)x
+{
+  /* For positive x, the following will leave super.count
+     unchanged.  */
+  super.count++;
+  --super.count;
+
+  super.count = (x < 0 ? x : super.count);
+  
+  if ((x = super.count))
+    super.count += 1;
+
+  if ((x = super.count))
+    super.count -= 1;
+
+  /* Finally, also put a bit of self.count in the mix.  */
+  self.count++;
+  super.count--;
+
+  return super.count;
+}
+@end
+
+int main (void)
+{
+  MySubClass *object = [[MySubClass alloc] init];
+
+  object.count = 10;
+  if (object.count != 10)
+    abort ();
+
+  object.superCount = 11;
+  if (object.superCount != 11)
+    abort ();
+
+  object.superCount2 = 12;
+  if (object.superCount2 != 12)
+    abort ();
+
+  if ([object test: 45] != 12)
+    abort ();
+
+  return 0;
+}