diff options
author | Ziemowit Laski <zlaski@apple.com> | 2003-09-25 01:26:01 +0000 |
---|---|---|
committer | Ziemowit Laski <zlaski@gcc.gnu.org> | 2003-09-25 01:26:01 +0000 |
commit | 264fa2db22ce7cf50ebb108edb097acf0c9f2a57 (patch) | |
tree | 1052b4d25cc404c17e6402e22b8183026f4d4263 /gcc/testsuite/objc.dg/proto-qual-1.m | |
parent | 3b6fdb2fa04453ebf17ec1dfd3ef62b413442430 (diff) | |
download | gcc-264fa2db22ce7cf50ebb108edb097acf0c9f2a57.tar.gz |
MERGE OF objc-improvements-branch into MAINLINE.
2003-09-24 Ziemowit Laski <zlaski@apple.com>
MERGE OF objc-improvements-branch into MAINLINE.
See 'gcc/ChangeLog' and 'gcc/testsuite/ChangeLog' for
the gory details.
From-SVN: r71748
Diffstat (limited to 'gcc/testsuite/objc.dg/proto-qual-1.m')
-rw-r--r-- | gcc/testsuite/objc.dg/proto-qual-1.m | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gcc/testsuite/objc.dg/proto-qual-1.m b/gcc/testsuite/objc.dg/proto-qual-1.m new file mode 100644 index 00000000000..6ae12909380 --- /dev/null +++ b/gcc/testsuite/objc.dg/proto-qual-1.m @@ -0,0 +1,48 @@ +/* Check that protocol qualifiers are compiled and encoded properly. */ +/* Author: Ziemowit Laski <zlaski@apple.com> */ +/* { dg-options "-lobjc" } */ +/* { dg-do run } */ + +#include <objc/Protocol.h> +#ifndef __NEXT_RUNTIME__ +#include <objc/objc-api.h> +#endif + +extern int sscanf(const char *str, const char *format, ...); +extern void abort(void); +#define CHECK_IF(expr) if(!(expr)) abort() + +@protocol Retain ++ (oneway void)retainArgument:(out bycopy id)arg1 with:(in signed char **)arg2; +- (bycopy) address:(byref inout id)location with:(out short unsigned **)arg2; +@end + +@interface Foo <Retain> ++ (oneway void)retainArgument:(out bycopy id)arg with:(in signed char **)arg2; +@end + +@implementation Foo ++ (oneway void)retainArgument:(out bycopy id)arg1 with:(in signed char **)arg2 { } +- (bycopy) address:(byref inout id)location with:(out short unsigned **)arg2 { return nil; } +@end + +Protocol *proto = @protocol(Retain); +struct objc_method_description *meth; +unsigned totsize, offs0, offs1, offs2, offs3, offs4, offs5, offs6, offs7; + +static void scan_initial(const char *pattern) { + totsize = offs0 = offs1 = offs2 = offs3 = offs4 = offs5 = offs6 = offs7 = (unsigned)-1; + sscanf(meth->types, pattern, &totsize, &offs0, &offs1, &offs2, &offs3, + &offs4, &offs5, &offs6, &offs7); + CHECK_IF(!offs0 && offs1 == sizeof(id) && offs2 == offs1 + sizeof(SEL) && totsize >= offs2); +} + +int main(void) { + meth = [proto descriptionForInstanceMethod: @selector(address:with:)]; + scan_initial("O@%u@%u:%uNR@%uo^^S%u"); + CHECK_IF(offs3 == offs2 + sizeof(id) && totsize == offs3 + sizeof(unsigned)); + meth = [proto descriptionForClassMethod: @selector(retainArgument:with:)]; + scan_initial("Vv%u@%u:%uOo@%un^*%u"); + CHECK_IF(offs3 == offs2 + sizeof(id) && totsize == offs3 + sizeof(char **)); + return 0; +} |