From c03bc36d9d581a77f9024f43acf37830e4fac9ef Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Thu, 13 Dec 2001 13:41:07 +0100 Subject: [PATCH] New objc tests for bitfield enumeration ivars From-SVN: r47971 --- gcc/testsuite/ChangeLog | 6 +++ gcc/testsuite/objc/execute/bf-21.m | 20 +++++++++ gcc/testsuite/objc/execute/enumeration-1.m | 49 +++++++++++++++++++++ gcc/testsuite/objc/execute/enumeration-2.m | 51 ++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 gcc/testsuite/objc/execute/bf-21.m create mode 100644 gcc/testsuite/objc/execute/enumeration-1.m create mode 100644 gcc/testsuite/objc/execute/enumeration-2.m diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 489171423d4..4f559ed6739 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +Thu Dec 13 10:35:33 2001 Nicola Pero + + * objc/execute/bf-21.m: New test. + * objc/execute/enumeration-1.m: New test. + * objc/execute/enumeration-2.m: New test. + 2001-12-12 Jakub Jelinek * gcc.dg/gnu89-init-1.c: New test. diff --git a/gcc/testsuite/objc/execute/bf-21.m b/gcc/testsuite/objc/execute/bf-21.m new file mode 100644 index 00000000000..2587a0acd14 --- /dev/null +++ b/gcc/testsuite/objc/execute/bf-21.m @@ -0,0 +1,20 @@ +#include +#include +#include + +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 00000000000..e0b784f9887 --- /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 +#include + +/* 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 00000000000..a128da69ff3 --- /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 +#include + +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; +} -- 2.30.2