aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc
diff options
context:
space:
mode:
authorNicola Pero <n.pero@mi.flashnet.it>2001-12-13 13:41:07 +0100
committerNicola Pero <nicola@gcc.gnu.org>2001-12-13 12:41:07 +0000
commitc03bc36d9d581a77f9024f43acf37830e4fac9ef (patch)
tree783900f747169359d0e7527bfa759edfafee2d54 /gcc/testsuite/objc
parentc48f792ceebf46a23ed07a682e3288af59012832 (diff)
downloadgcc-c03bc36d9d581a77f9024f43acf37830e4fac9ef.zip
gcc-c03bc36d9d581a77f9024f43acf37830e4fac9ef.tar.gz
gcc-c03bc36d9d581a77f9024f43acf37830e4fac9ef.tar.bz2
New objc tests for bitfield enumeration ivars
From-SVN: r47971
Diffstat (limited to 'gcc/testsuite/objc')
-rw-r--r--gcc/testsuite/objc/execute/bf-21.m20
-rw-r--r--gcc/testsuite/objc/execute/enumeration-1.m49
-rw-r--r--gcc/testsuite/objc/execute/enumeration-2.m51
3 files changed, 120 insertions, 0 deletions
diff --git a/gcc/testsuite/objc/execute/bf-21.m b/gcc/testsuite/objc/execute/bf-21.m
new file mode 100644
index 0000000..2587a0a
--- /dev/null
+++ b/gcc/testsuite/objc/execute/bf-21.m
@@ -0,0 +1,20 @@
+#include <objc/objc.h>
+#include <objc/objc-api.h>
+#include <objc/Object.h>
+
+typedef enum
+{
+ A, B
+} enumeration;
+
+@interface MyObject
+{
+ enumeration g:4;
+}
+@end
+
+@implementation MyObject
+@end
+
+#include "bf-common.h"
+
diff --git a/gcc/testsuite/objc/execute/enumeration-1.m b/gcc/testsuite/objc/execute/enumeration-1.m
new file mode 100644
index 0000000..e0b784f
--- /dev/null
+++ b/gcc/testsuite/objc/execute/enumeration-1.m
@@ -0,0 +1,49 @@
+/* Contributed by Nicola Pero - Wed Dec 5 17:12:40 GMT 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+/* Test using a bitfield enumeration ivar. */
+
+typedef enum
+{
+ black,
+ white
+} color;
+
+@interface TestClass: Object
+{
+ color c:2;
+}
+- (color)color;
+- (void)setColor: (color)a;
+@end
+
+@implementation TestClass
+- (color)color
+{
+ return c;
+}
+- (void)setColor: (color)a
+{
+ c = a;
+}
+@end
+
+
+int main (void)
+{
+ TestClass *c;
+
+ c = [TestClass new];
+
+ [c setColor: black];
+ [c setColor: white];
+ [c setColor: black];
+ if ([c color] != black)
+ {
+ abort ();
+ }
+
+
+ return 0;
+}
diff --git a/gcc/testsuite/objc/execute/enumeration-2.m b/gcc/testsuite/objc/execute/enumeration-2.m
new file mode 100644
index 0000000..a128da6
--- /dev/null
+++ b/gcc/testsuite/objc/execute/enumeration-2.m
@@ -0,0 +1,51 @@
+/* Contributed by Nicola Pero - Wed Dec 5 17:12:40 GMT 2001 */
+#include <objc/objc.h>
+#include <objc/Object.h>
+
+typedef enum { black, white } color;
+
+typedef struct
+{
+ color a:2;
+ color b:2;
+} color_couple;
+
+@interface TestClass: Object
+{
+ color_couple *c;
+}
+- (color_couple *)colorCouple;
+- (void)setColorCouple: (color_couple *)a;
+@end
+
+@implementation TestClass
+- (color_couple *)colorCouple
+{
+ return c;
+}
+- (void)setColorCouple: (color_couple *)a
+{
+ c = a;
+}
+@end
+
+
+int main (void)
+{
+ color_couple cc;
+ TestClass *c;
+
+ c = [TestClass new];
+
+ cc.a = black;
+ cc.b = white;
+
+ [c setColorCouple: &cc];
+ if ([c colorCouple] != &cc)
+ {
+ abort ();
+ }
+
+
+ return 0;
+}