mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-28 00:25:46 +08:00
New objc tests for bitfield enumeration ivars
From-SVN: r47971
This commit is contained in:
parent
c48f792cee
commit
c03bc36d9d
@ -1,3 +1,9 @@
|
||||
Thu Dec 13 10:35:33 2001 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
* 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 <jakub@redhat.com>
|
||||
|
||||
* gcc.dg/gnu89-init-1.c: New test.
|
||||
|
20
gcc/testsuite/objc/execute/bf-21.m
Normal file
20
gcc/testsuite/objc/execute/bf-21.m
Normal file
@ -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"
|
||||
|
49
gcc/testsuite/objc/execute/enumeration-1.m
Normal file
49
gcc/testsuite/objc/execute/enumeration-1.m
Normal file
@ -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;
|
||||
}
|
51
gcc/testsuite/objc/execute/enumeration-2.m
Normal file
51
gcc/testsuite/objc/execute/enumeration-2.m
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user