From 1bc5aee63eb72b341f506ad058502cd0361f0d10 Mon Sep 17 00:00:00 2001 From: Ben Cheng Date: Tue, 25 Mar 2014 22:37:19 -0700 Subject: Initial checkin of GCC 4.9.0 from trunk (r208799). Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba --- gcc-4.9/gcc/testsuite/objc/compile/20011211-1.m | 19 +++ gcc-4.9/gcc/testsuite/objc/compile/20060406-1.m | 65 ++++++++++ gcc-4.9/gcc/testsuite/objc/compile/compile.exp | 45 +++++++ gcc-4.9/gcc/testsuite/objc/compile/method-1.m | 12 ++ gcc-4.9/gcc/testsuite/objc/compile/pr18406.m | 9 ++ gcc-4.9/gcc/testsuite/objc/compile/trivial.m | 6 + gcc-4.9/gcc/testsuite/objc/execute/IMP.m | 39 ++++++ gcc-4.9/gcc/testsuite/objc/execute/_cmd.m | 32 +++++ .../gcc/testsuite/objc/execute/accessing_ivars.m | 55 +++++++++ gcc-4.9/gcc/testsuite/objc/execute/bf-1.m | 22 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-10.m | 19 +++ gcc-4.9/gcc/testsuite/objc/execute/bf-11.m | 21 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-12.m | 21 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-13.m | 23 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-14.m | 22 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-15.m | 23 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-16.m | 23 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-17.m | 22 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-18.m | 15 +++ gcc-4.9/gcc/testsuite/objc/execute/bf-19.m | 14 +++ gcc-4.9/gcc/testsuite/objc/execute/bf-2.m | 22 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-20.m | 13 ++ gcc-4.9/gcc/testsuite/objc/execute/bf-21.m | 18 +++ gcc-4.9/gcc/testsuite/objc/execute/bf-3.m | 22 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-4.m | 22 ++++ gcc-4.9/gcc/testsuite/objc/execute/bf-5.m | 20 +++ gcc-4.9/gcc/testsuite/objc/execute/bf-6.m | 20 +++ gcc-4.9/gcc/testsuite/objc/execute/bf-7.m | 19 +++ gcc-4.9/gcc/testsuite/objc/execute/bf-8.m | 20 +++ gcc-4.9/gcc/testsuite/objc/execute/bf-9.m | 20 +++ gcc-4.9/gcc/testsuite/objc/execute/bf-common.h | 136 +++++++++++++++++++++ gcc-4.9/gcc/testsuite/objc/execute/bycopy-1.m | 18 +++ gcc-4.9/gcc/testsuite/objc/execute/bycopy-2.m | 30 +++++ gcc-4.9/gcc/testsuite/objc/execute/bycopy-3.m | 102 ++++++++++++++++ gcc-4.9/gcc/testsuite/objc/execute/cascading-1.m | 34 ++++++ gcc-4.9/gcc/testsuite/objc/execute/class-1.m | 23 ++++ gcc-4.9/gcc/testsuite/objc/execute/class-10.m | 78 ++++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-11.m | 82 +++++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-12.m | 51 ++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-13.m | 72 +++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-14.m | 77 ++++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-2.m | 29 +++++ gcc-4.9/gcc/testsuite/objc/execute/class-3.m | 43 +++++++ gcc-4.9/gcc/testsuite/objc/execute/class-4.m | 53 ++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-5.m | 72 +++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-6.m | 72 +++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-7.m | 67 ++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-8.m | 75 ++++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-9.m | 75 ++++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-tests-1.h | 114 +++++++++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class-tests-2.h | 67 ++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class_self-1.m | 63 ++++++++++ gcc-4.9/gcc/testsuite/objc/execute/class_self-2.m | 68 +++++++++++ .../testsuite/objc/execute/compatibility_alias.m | 12 ++ gcc-4.9/gcc/testsuite/objc/execute/encode-1.m | 31 +++++ gcc-4.9/gcc/testsuite/objc/execute/enumeration-1.m | 50 ++++++++ gcc-4.9/gcc/testsuite/objc/execute/enumeration-2.m | 52 ++++++++ .../testsuite/objc/execute/exceptions/catchall-1.m | 77 ++++++++++++ .../objc/execute/exceptions/exceptions.exp | 49 ++++++++ .../testsuite/objc/execute/exceptions/finally-1.m | 60 +++++++++ .../testsuite/objc/execute/exceptions/foward-1.m | 42 +++++++ .../testsuite/objc/execute/exceptions/foward-1.x | 11 ++ .../testsuite/objc/execute/exceptions/handler-1.m | 53 ++++++++ .../objc/execute/exceptions/local-variables-1.m | 63 ++++++++++ .../testsuite/objc/execute/exceptions/matcher-1.m | 68 +++++++++++ .../testsuite/objc/execute/exceptions/pr31281.m | 27 ++++ .../testsuite/objc/execute/exceptions/throw-nil.m | 50 ++++++++ .../testsuite/objc/execute/exceptions/trivial.m | 17 +++ gcc-4.9/gcc/testsuite/objc/execute/execute.exp | 46 +++++++ gcc-4.9/gcc/testsuite/objc/execute/fdecl.m | 19 +++ .../gcc/testsuite/objc/execute/formal_protocol-1.m | 45 +++++++ .../gcc/testsuite/objc/execute/formal_protocol-2.m | 46 +++++++ .../gcc/testsuite/objc/execute/formal_protocol-3.m | 59 +++++++++ .../gcc/testsuite/objc/execute/formal_protocol-4.m | 41 +++++++ .../gcc/testsuite/objc/execute/formal_protocol-5.m | 34 ++++++ .../gcc/testsuite/objc/execute/formal_protocol-6.m | 27 ++++ .../gcc/testsuite/objc/execute/formal_protocol-7.m | 45 +++++++ .../testsuite/objc/execute/function-message-1.m | 33 +++++ .../gcc/testsuite/objc/execute/informal_protocol.m | 13 ++ gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m | 47 +++++++ gcc-4.9/gcc/testsuite/objc/execute/initialize.m | 36 ++++++ gcc-4.9/gcc/testsuite/objc/execute/load-2.m | 46 +++++++ gcc-4.9/gcc/testsuite/objc/execute/load-3.m | 109 +++++++++++++++++ gcc-4.9/gcc/testsuite/objc/execute/load.m | 30 +++++ .../gcc/testsuite/objc/execute/many_args_method.m | 57 +++++++++ gcc-4.9/gcc/testsuite/objc/execute/nested-1.m | 12 ++ gcc-4.9/gcc/testsuite/objc/execute/nested-2.m | 17 +++ gcc-4.9/gcc/testsuite/objc/execute/nested-3.m | 38 ++++++ gcc-4.9/gcc/testsuite/objc/execute/nested-func-1.m | 36 ++++++ gcc-4.9/gcc/testsuite/objc/execute/nil_method-1.m | 61 +++++++++ gcc-4.9/gcc/testsuite/objc/execute/no_clash.m | 42 +++++++ gcc-4.9/gcc/testsuite/objc/execute/np-1.m | 30 +++++ gcc-4.9/gcc/testsuite/objc/execute/np-2.m | 30 +++++ .../gcc/testsuite/objc/execute/object_is_class.m | 42 +++++++ .../testsuite/objc/execute/object_is_meta_class.m | 42 +++++++ gcc-4.9/gcc/testsuite/objc/execute/pr25328.m | 11 ++ gcc-4.9/gcc/testsuite/objc/execute/private.m | 32 +++++ .../testsuite/objc/execute/protocol-isEqual-1.m | 21 ++++ .../testsuite/objc/execute/protocol-isEqual-2.m | 23 ++++ .../testsuite/objc/execute/protocol-isEqual-3.m | 19 +++ .../testsuite/objc/execute/protocol-isEqual-4.m | 20 +++ gcc-4.9/gcc/testsuite/objc/execute/protocol.m | 21 ++++ .../gcc/testsuite/objc/execute/redefining_self.m | 32 +++++ gcc-4.9/gcc/testsuite/objc/execute/root_methods.m | 45 +++++++ gcc-4.9/gcc/testsuite/objc/execute/selector-1.m | 17 +++ gcc-4.9/gcc/testsuite/objc/execute/static-1.m | 35 ++++++ gcc-4.9/gcc/testsuite/objc/execute/static-2.m | 38 ++++++ gcc-4.9/gcc/testsuite/objc/execute/trivial.m | 8 ++ gcc-4.9/gcc/testsuite/objc/execute/va_method.m | 45 +++++++ 109 files changed, 4316 insertions(+) create mode 100644 gcc-4.9/gcc/testsuite/objc/compile/20011211-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/compile/20060406-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/compile/compile.exp create mode 100644 gcc-4.9/gcc/testsuite/objc/compile/method-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/compile/pr18406.m create mode 100644 gcc-4.9/gcc/testsuite/objc/compile/trivial.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/IMP.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/_cmd.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/accessing_ivars.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-10.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-11.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-12.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-13.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-14.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-15.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-16.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-17.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-18.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-19.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-20.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-21.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-3.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-4.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-5.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-6.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-7.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-8.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-9.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bf-common.h create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bycopy-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bycopy-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/bycopy-3.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/cascading-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-10.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-11.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-12.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-13.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-14.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-3.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-4.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-5.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-6.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-7.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-8.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-9.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-tests-1.h create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class-tests-2.h create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class_self-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/class_self-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/compatibility_alias.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/encode-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/enumeration-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/enumeration-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/catchall-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/exceptions.exp create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/finally-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/foward-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/foward-1.x create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/handler-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/local-variables-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/matcher-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/pr31281.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/throw-nil.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/exceptions/trivial.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/execute.exp create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/fdecl.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-3.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-4.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-5.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-6.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-7.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/function-message-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/informal_protocol.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/initialize.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/load-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/load-3.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/load.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/many_args_method.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/nested-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/nested-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/nested-3.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/nested-func-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/nil_method-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/no_clash.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/np-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/np-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/object_is_class.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/object_is_meta_class.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/pr25328.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/private.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-3.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-4.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/protocol.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/redefining_self.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/root_methods.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/selector-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/static-1.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/static-2.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/trivial.m create mode 100644 gcc-4.9/gcc/testsuite/objc/execute/va_method.m (limited to 'gcc-4.9/gcc/testsuite/objc') diff --git a/gcc-4.9/gcc/testsuite/objc/compile/20011211-1.m b/gcc-4.9/gcc/testsuite/objc/compile/20011211-1.m new file mode 100644 index 000000000..b6920019c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/compile/20011211-1.m @@ -0,0 +1,19 @@ +typedef struct objc_class *Class; + +typedef struct objc_object { + Class isa; +} *id; + +@interface nsset ++ (id)set; +@end + +@interface baz +- (void)set; +@end + +nsset *fn () +{ + nsset *bar; + bar = [nsset set]; +} diff --git a/gcc-4.9/gcc/testsuite/objc/compile/20060406-1.m b/gcc-4.9/gcc/testsuite/objc/compile/20060406-1.m new file mode 100644 index 000000000..62148902a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/compile/20060406-1.m @@ -0,0 +1,65 @@ +/* This test tests typedefs and protocol qualifiers. */ + +@protocol O +- (unsigned)j; +@end + +@interface T +@end + + +/* First test. */ +typedef T *S; + +@interface I ++ (unsigned char)T:(S[2])p + v:(S)h; +@end + +@implementation I ++ (unsigned char)T:(S[2])p + v:(S)h +{ + p[0] = (S) 0; + p[1] = (S) 0; + return 0; +} +@end + + +/* Second test. */ +typedef T S1; + +@interface I1 ++ (unsigned char)T1:(S1*[2])p + v1:(S1*)h; +@end + +@implementation I1 ++ (unsigned char)T1:(S1*[2])p + v1:(S1*)h +{ + p[0] = (S1*) 0; + p[1] = (S1*) 0; + return 0; +} +@end + + +/* Third test. */ +typedef T S2; + +@interface I2 ++ (unsigned char)T1:(S2*[2])p + v1:(S2*)h; +@end + +@implementation I2 ++ (unsigned char)T1:(S2*[2])p + v1:(S2*)h +{ + p[0] = (S2*) 0; + p[1] = (S2*) 0; + return 0; +} +@end diff --git a/gcc-4.9/gcc/testsuite/objc/compile/compile.exp b/gcc-4.9/gcc/testsuite/objc/compile/compile.exp new file mode 100644 index 000000000..4bf24a42e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/compile/compile.exp @@ -0,0 +1,45 @@ +# Copyright (C) 1991-2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# This file was written by Rob Savoye. (rob@cygnus.com) +# Modified by Stan Shebs + +if $tracelevel then { + strace $tracelevel +} + +# load support procs +load_lib objc-torture.exp +load_lib torture-options.exp + +torture-init +objc-set-runtime-options "compile" +set-torture-options $OBJC_TORTURE_OPTIONS $OBJC_RUNTIME_OPTIONS + +# +# main test loop +# + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.m]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + objc-torture $src +} + +torture-finish diff --git a/gcc-4.9/gcc/testsuite/objc/compile/method-1.m b/gcc-4.9/gcc/testsuite/objc/compile/method-1.m new file mode 100644 index 000000000..e9bb989be --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/compile/method-1.m @@ -0,0 +1,12 @@ +/* PR objc/29195 */ +/* Test that array decls are changed to a pointer type + correctly and make sure we don't crash because the + decl was not relayed out. */ + +@ implementation NGActiveSocket ++ (void) socketPair:(int [2]) + _pair +{ + _pair[0] = 0; +} +@end diff --git a/gcc-4.9/gcc/testsuite/objc/compile/pr18406.m b/gcc-4.9/gcc/testsuite/objc/compile/pr18406.m new file mode 100644 index 000000000..d34334f00 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/compile/pr18406.m @@ -0,0 +1,9 @@ +@interface Test +- (void)test: (long double)val; +@end + +@implementation Test +- (void)test: (long double)val +{ +} +@end diff --git a/gcc-4.9/gcc/testsuite/objc/compile/trivial.m b/gcc-4.9/gcc/testsuite/objc/compile/trivial.m new file mode 100644 index 000000000..b0639d459 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/compile/trivial.m @@ -0,0 +1,6 @@ +#import "../../objc-obj-c++-shared/TestsuiteObject.h" + +int main(void) +{ + [TestsuiteObject class]; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/IMP.m b/gcc-4.9/gcc/testsuite/objc/execute/IMP.m new file mode 100644 index 000000000..a2372cba7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/IMP.m @@ -0,0 +1,39 @@ +/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */ + +#include +#include "../../objc-obj-c++-shared/runtime.h" + +/* Test getting and calling the IMP of a method */ + +@interface TestClass +{ + Class isa; +} ++ (int) next: (int)a; +@end + +@implementation TestClass ++ (int) next: (int)a +{ + return a + 1; +} +@end + +int main (void) +{ + Class class; + SEL selector; + int (* imp) (id, SEL, int); + + class = objc_getClass ("TestClass"); + selector = @selector (next:); + imp = (int (*)(id, SEL, int))method_getImplementation + (class_getClassMethod (class, selector)); + + if (imp (class, selector, 5) != 6) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/_cmd.m b/gcc-4.9/gcc/testsuite/objc/execute/_cmd.m new file mode 100644 index 000000000..7e176e991 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/_cmd.m @@ -0,0 +1,32 @@ +/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */ + +#include +#include "../../objc-obj-c++-shared/runtime.h" + +/* Test the hidden argument _cmd to method calls */ + +@interface TestClass +{ + Class isa; +} ++ (const char*) method; +@end + +@implementation TestClass ++ (const char*) method +{ + return sel_getName (_cmd); +} ++ initialize { return self; } +@end + + +int main (void) +{ + if (strcmp ([TestClass method], "method")) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/accessing_ivars.m b/gcc-4.9/gcc/testsuite/objc/execute/accessing_ivars.m new file mode 100644 index 000000000..964c378b4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/accessing_ivars.m @@ -0,0 +1,55 @@ +/* Contributed by Nicola Pero - Thu Mar 8 16:27:46 CET 2001 */ +#include +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +/* Test that by using -> we can access ivars of other objects of the same + class */ + +@interface TestClass : TestsuiteObject +{ + int value; +} +- (int) value; +- (void) setValue: (int)number; +- (void) takeValueFrom: (TestClass *)object; +@end + +@implementation TestClass : TestsuiteObject +{ + int value; +} +- (int) value +{ + return value; +} +- (void) setValue: (int)number +{ + value = number; +} +- (void) takeValueFrom: (TestClass *)object +{ + value = object->value; +} +@end + +int main (void) +{ + TestClass *a; + TestClass *b; + + a = [TestClass new]; + [a setValue: 10]; + + b = [TestClass new]; + [b setValue: -10]; + + [b takeValueFrom: a]; + + if ([b value] != [a value]) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-1.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-1.m new file mode 100644 index 000000000..a5d219108 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-1.m @@ -0,0 +1,22 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a; + struct { + int i:2; + int j:3; + int k:12; + } flags; + char c; +// void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-10.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-10.m new file mode 100644 index 000000000..6cbdc225b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-10.m @@ -0,0 +1,19 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a[3]; + int i:2; + int j:6; + char c; + int k:12; + char d; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-11.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-11.m new file mode 100644 index 000000000..42a97a57a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-11.m @@ -0,0 +1,21 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a[3]; + int i:2; + int j:6; + short s; + int k:12; + char d; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-12.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-12.m new file mode 100644 index 000000000..78a19d306 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-12.m @@ -0,0 +1,21 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a[3]; + int i:2; + int j:6; + int s; + int k:12; + char d; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-13.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-13.m new file mode 100644 index 000000000..fa47238b0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-13.m @@ -0,0 +1,23 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a[3]; + struct { + int i:2; + int j:6; + char s; + int k:12; + } flags; + char d; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-14.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-14.m new file mode 100644 index 000000000..99fa8fef5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-14.m @@ -0,0 +1,22 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a[3]; + struct { + int i:2; + int j:6; + short s; + int k:12; + } flags; + char d; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-15.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-15.m new file mode 100644 index 000000000..c32e66331 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-15.m @@ -0,0 +1,23 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a; + struct { + int i:2; + int j:6; + int s; + int k:12; + } flags; + char d; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-16.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-16.m new file mode 100644 index 000000000..e286de7c2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-16.m @@ -0,0 +1,23 @@ +#include + +struct A { + int i; + float f; + int a:3; + int b:2; +}; + +@interface MyObject +{ + Class isa; + int i; + float f[3]; + struct A a, b; + char c; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-17.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-17.m new file mode 100644 index 000000000..7650ffae7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-17.m @@ -0,0 +1,22 @@ +#include + +struct A { + int i; + float f; + int a:3; + int b:2; +}; + +@interface MyObject +{ + Class isa; + int i; + float f[3]; + struct A a; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-18.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-18.m new file mode 100644 index 000000000..528829554 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-18.m @@ -0,0 +1,15 @@ +#include + +@interface MyObject +{ + Class isa; + int i; + char c[1]; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-19.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-19.m new file mode 100644 index 000000000..d9306df00 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-19.m @@ -0,0 +1,14 @@ +#include + +@interface MyObject +{ + Class isa; + unsigned int i; + MyObject *object; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-2.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-2.m new file mode 100644 index 000000000..f776eea5d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-2.m @@ -0,0 +1,22 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a[3]; + struct { + int i:2; + int j:3; + int k:12; + } flags; + char c; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-20.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-20.m new file mode 100644 index 000000000..311a0fd5b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-20.m @@ -0,0 +1,13 @@ +#include + +@interface MyObject +{ + short s; + char c; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-21.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-21.m new file mode 100644 index 000000000..587060d1d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-21.m @@ -0,0 +1,18 @@ +#include + +typedef enum +{ + A, B +} enumeration; + +@interface MyObject +{ + enumeration g:4; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-3.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-3.m new file mode 100644 index 000000000..52863bb6f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-3.m @@ -0,0 +1,22 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a; + struct { + int i:2; + int j:6; + int k:12; + } flags; + char c; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-4.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-4.m new file mode 100644 index 000000000..5654b6fed --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-4.m @@ -0,0 +1,22 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a[3]; + struct { + int i:2; + int j:6; + int k:12; + } flags; + char c; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-5.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-5.m new file mode 100644 index 000000000..b75509ddd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-5.m @@ -0,0 +1,20 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a; + int i:2; + int j:3; + int k:12; + char c; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-6.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-6.m new file mode 100644 index 000000000..187c7582d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-6.m @@ -0,0 +1,20 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a[3]; + int i:2; + int j:3; + int k:12; + char c; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-7.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-7.m new file mode 100644 index 000000000..f1ee46e0c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-7.m @@ -0,0 +1,19 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a; + int i:2; + int j:6; + int k:12; + char c; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-8.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-8.m new file mode 100644 index 000000000..164950fca --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-8.m @@ -0,0 +1,20 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a[3]; + int i:2; + int j:6; + int k:12; + char c; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-9.m b/gcc-4.9/gcc/testsuite/objc/execute/bf-9.m new file mode 100644 index 000000000..9fc7c704b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-9.m @@ -0,0 +1,20 @@ +#include + +@interface MyObject +{ + Class isa; + float f; + char a[3]; + int i:2; + int j:3; + char c; + int k:12; + char d; + void *pointer; +} +@end + +@implementation MyObject +@end + +#include "bf-common.h" diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bf-common.h b/gcc-4.9/gcc/testsuite/objc/execute/bf-common.h new file mode 100644 index 000000000..43b0d32b7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bf-common.h @@ -0,0 +1,136 @@ +#include +#include + +#include "../../objc-obj-c++-shared/runtime.h" + +/* The following header, together with the implementation included below, + emulate functionality provided by the GNU runtime but not available from + the NeXT runtime. */ +#include "../../objc-obj-c++-shared/objc-test-suite-next-encode-assist.h" + +#if defined(__NEXT_RUNTIME__) && !defined(NEXT_OBJC_USE_NEW_INTERFACE) +void print_ivars (Class class) +{ + struct objc_ivar_list* ivars = class->ivars; + int i; + + for (i = 0; i < ivars->ivar_count; i++) { + struct objc_ivar *ivar = &(ivars->ivar_list[i]); + printf ("ivar '%s', type '%s', offset %d\n", + ivar->ivar_name, ivar->ivar_type, ivar->ivar_offset); + } +} + +void compare_structures (Class class, const char* type) +{ + struct objc_struct_layout layout; + struct objc_ivar_list* ivars = class->ivars; + int i = 0; + int position; + + objc_layout_structure (type, &layout); + + while (objc_layout_structure_next_member (&layout)) + { + struct objc_ivar *ivar; + const char *ivar_type; + + if (i > ivars->ivar_count) + { + printf ("too many ivars in type %s, layout = %s\n", + type, layout.type); + exit (1); + } + + ivar = &(ivars->ivar_list[i]); + objc_layout_structure_get_info (&layout, &position, NULL, &ivar_type); + printf ("real ivar '%s' offset %d\n", + ivar->ivar_name, ivar->ivar_offset); + printf ("computed type '%s' offset %d\n", ivar_type, position); + if (position != ivar->ivar_offset) + { + printf ("offset %d and computed position %d don't match on ivar '%s'" + " (i = %d)\n", + ivar->ivar_offset, position, ivar->ivar_name, i); + exit (1); + } + i++; + } + + printf ("%d ivars checked\n", i); +} +#else +void print_ivars (Class class) +{ + unsigned int count, i; + Ivar *list = class_copyIvarList (class, &count); + + for (i = 0; i < count; i++) { + printf ("ivar '%s', type '%s', offset %ud\n", + ivar_getName (list[i]), + ivar_getTypeEncoding (list[i]), + (unsigned int)ivar_getOffset (list[i])); + } +} + +void compare_structures (Class class, const char* type) +{ + struct objc_struct_layout layout; + unsigned int count; + Ivar *list = class_copyIvarList (class, &count); + int i = 0; + int position; + + objc_layout_structure (type, &layout); + + while (objc_layout_structure_next_member (&layout)) + { + const char *ivar_type; + + if (i > count) + { + printf ("too many ivars in type %s, layout = %s\n", + type, layout.type); + exit (1); + } + + objc_layout_structure_get_info (&layout, &position, NULL, &ivar_type); + printf ("real ivar '%s' offset %ud\n", + ivar_getName (list[i]), (unsigned int)ivar_getOffset (list[i])); + printf ("computed type '%s' offset %d\n", ivar_type, position); + if ((unsigned int)position != (unsigned int)ivar_getOffset (list[i])) + { + printf ("offset %ud and computed position %d don't match on ivar '%s'" + " (i = %d)\n", + (unsigned int)ivar_getOffset (list[i]), position, ivar_getName (list[i]), i); + exit (1); + } + i++; + } + + printf ("%d ivars checked\n", i); +} +#endif + +int main () +{ + struct class_vars + { + @defs (MyObject); + }; + int size1, size2; + Class class = objc_getClass ("MyObject"); + printf ("type = %s\n", @encode (struct class_vars)); + print_ivars (class); + + compare_structures (class, @encode(struct class_vars)); + if ((size1 = objc_sizeof_type (@encode(struct class_vars))) + != (size2 = sizeof (struct class_vars))) + { + printf ("sizes don't match (computed %d, exact %d)\n", size1, size2); + abort (); + } + + return 0; +} +#include "../../objc-obj-c++-shared/objc-test-suite-next-encode-assist-impl.h" diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bycopy-1.m b/gcc-4.9/gcc/testsuite/objc/execute/bycopy-1.m new file mode 100644 index 000000000..358b6f92b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bycopy-1.m @@ -0,0 +1,18 @@ +/* + * Contributed by Nicola Pero + * Fri Feb 2 11:48:01 GMT 2001 + */ +#include + +@protocol MyProtocol +- (bycopy id) bycopyMethod; +@end + +int main (void) +{ + [nil bycopyMethod]; + + return 0; +} + + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bycopy-2.m b/gcc-4.9/gcc/testsuite/objc/execute/bycopy-2.m new file mode 100644 index 000000000..b42659106 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bycopy-2.m @@ -0,0 +1,30 @@ +/* + * Contributed by Nicola Pero + * Fri Feb 2 11:48:01 GMT 2001 + */ +#include +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +@protocol MyProtocol ++ (bycopy id) bycopyMethod; +@end + +@interface MyObject : TestsuiteObject +@end + +@implementation MyObject ++ (bycopy id) bycopyMethod +{ + return [MyObject alloc]; +} +@end + +int main (void) +{ + MyObject *object; + + object = [MyObject bycopyMethod]; + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/bycopy-3.m b/gcc-4.9/gcc/testsuite/objc/execute/bycopy-3.m new file mode 100644 index 000000000..e96d39594 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/bycopy-3.m @@ -0,0 +1,102 @@ +/* + * Contributed by Nicola Pero + * Wed Feb 28 12:27:03 CET 2001 + */ + +/* + * This test contains some no-op code which is needed to keep it + * compile on broken gcc 3.x. Anyway, the no-op code does not + * interfere with what we are testing, which is that the `bycopy' + * keyword generates the _F_BYCOPY qualifier for the return type. */ + +extern int printf (const char *, ...); + +#include +#include "../../objc-obj-c++-shared/runtime.h" +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +@protocol MyProtocol ++ (bycopy id) bycopyMethod; +@end + +/* This no-op class to keep it compile under broken gcc 3.x */ +@interface MyObject : TestsuiteObject +@end + +@implementation MyObject ++ (bycopy id) bycopyMethod +{ + return [MyObject alloc]; +} +@end + +/* The following header, together with the implementation included below, + emulate functionality provided by the GNU runtime but not available from + the NeXT runtime. */ +#include "../../objc-obj-c++-shared/objc-test-suite-next-encode-assist.h" + +int main (void) +{ + struct objc_method_description method; + const char *method_types; + unsigned qualifiers; + Protocol *protocol; + /* This no-op command is needed to keep the test compile on broken + gcc 3.x */ + MyObject *object = [MyObject bycopyMethod]; + + /* Get the protocol object */ + protocol = @protocol (MyProtocol); + + /* Ask to the protocol for the description of the method bycopyMethod */ + method = protocol_getMethodDescription (protocol, @selector (bycopyMethod), + YES, NO); + + /* Get the method types for the method - which encode return type, + arguments etc. */ + method_types = method.types; + + if (method_types == NULL) + { + printf ("Could not find method bycopyMethod in protocol!\n"); + return 1; + } + + /* Get the qualifiers for the return type */ + qualifiers = objc_get_type_qualifiers (method_types); + + /* If _F_BYCOPY is not there, the compiler is broken */ + if (! (qualifiers & _F_BYCOPY)) + { + printf ("Failed - selector does not contain _F_BYCOPY qualifier!\n"); + return 1; + } + + /* Else, happy end */ + return 0; +} + +#ifdef __NEXT_RUNTIME__ +unsigned +objc_get_type_qualifiers (const char *type) +{ + unsigned res = 0; + BOOL flag = YES; + + while (flag) + switch (*type++) + { + case _C_CONST: res |= _F_CONST; break; + case _C_IN: res |= _F_IN; break; + case _C_INOUT: res |= _F_INOUT; break; + case _C_OUT: res |= _F_OUT; break; + case _C_BYCOPY: res |= _F_BYCOPY; break; + case _C_BYREF: res |= _F_BYREF; break; + case _C_ONEWAY: res |= _F_ONEWAY; break; + case _C_GCINVISIBLE: res |= _F_GCINVISIBLE; break; + default: flag = NO; + } + + return res; +} +#endif diff --git a/gcc-4.9/gcc/testsuite/objc/execute/cascading-1.m b/gcc-4.9/gcc/testsuite/objc/execute/cascading-1.m new file mode 100644 index 000000000..0e4ea31b7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/cascading-1.m @@ -0,0 +1,34 @@ +#include +#import "../../objc-obj-c++-shared/TestsuiteObject.m" + +@interface Foo : TestsuiteObject ++ foo; ++ bar; +@end + +int foocalled = 0; +int barcalled = 0; + + +@implementation Foo ++ foo +{ + if (foocalled) + abort (); + foocalled = 1; + return self; +} ++ bar +{ + if (barcalled) + abort (); + barcalled = 1; + return self; +} +@end + +int main(int argc,char **argv) +{ + [[Foo foo] bar]; + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-1.m b/gcc-4.9/gcc/testsuite/objc/execute/class-1.m new file mode 100644 index 000000000..6ce262095 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-1.m @@ -0,0 +1,23 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a RootClass */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass +@end + +#include "class-tests-1.h" + +int main (void) +{ + test_class_with_superclass ("RootClass", ""); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-10.m b/gcc-4.9/gcc/testsuite/objc/execute/class-10.m new file mode 100644 index 000000000..fba1a38a0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-10.m @@ -0,0 +1,78 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with an ivar and + accessor methods and a subclass overriding the superclass' + implementation, and using self to call another method of itself */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +@interface SubClass : RootClass +{ + int state; +} +- (void) setState: (int)number; +- (int) state; +@end + +@implementation SubClass +- (void) setState: (int)number +{ + state = number; +} +- (int) state +{ + return state; +} +@end + +@interface SubSubClass : SubClass +- (int) shift; +@end + +@implementation SubSubClass +- (int) state +{ + return state + [self shift]; +} +- (int) shift +{ + return 1; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass * +#include "class-tests-2.h" + +int main (void) +{ + SubClass *object; + SubSubClass *sub_object; + + test_class_with_superclass ("SubClass", "RootClass"); + test_that_class_has_instance_method ("SubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubClass", @selector (state)); + + test_class_with_superclass ("SubSubClass", "SubClass"); + test_that_class_has_instance_method ("SubSubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubSubClass", @selector (state)); + test_that_class_has_instance_method ("SubSubClass", @selector (shift)); + + object = class_createInstance (objc_getClass ("SubClass"), 0); + test_accessor_method (object, 0, -1, -1, 1, 1); + + sub_object = class_createInstance (objc_getClass ("SubSubClass"), 0); + test_accessor_method (sub_object, 1, -1, 0, 1, 2); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-11.m b/gcc-4.9/gcc/testsuite/objc/execute/class-11.m new file mode 100644 index 000000000..2cd6017d4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-11.m @@ -0,0 +1,82 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with an ivar and + accessor methods and a subclass overriding the superclass' + implementation and using self to call another method of itself - in + a category */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +@interface SubClass : RootClass +{ + int state; +} +- (void) setState: (int)number; +- (int) state; +@end + +@implementation SubClass +- (void) setState: (int)number +{ + state = number; +} +- (int) state +{ + return state; +} +@end + +@interface SubSubClass : SubClass +- (int) shift; +@end + +@implementation SubSubClass +- (int) shift +{ + return 1; +} +@end + +@implementation SubSubClass (Additions) +- (int) state +{ + return state + [self shift]; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass * +#include "class-tests-2.h" + +int main (void) +{ + SubClass *object; + SubSubClass *sub_object; + + test_class_with_superclass ("SubClass", "RootClass"); + test_that_class_has_instance_method ("SubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubClass", @selector (state)); + + test_class_with_superclass ("SubSubClass", "SubClass"); + test_that_class_has_instance_method ("SubSubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubSubClass", @selector (state)); + test_that_class_has_instance_method ("SubSubClass", @selector (shift)); + + object = class_createInstance (objc_getClass ("SubClass"), 0); + test_accessor_method (object, 0, -1, -1, 1, 1); + + sub_object = class_createInstance (objc_getClass ("SubSubClass"), 0); + test_accessor_method (sub_object, 1, -1, 0, 1, 2); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-12.m b/gcc-4.9/gcc/testsuite/objc/execute/class-12.m new file mode 100644 index 000000000..d3116e8cc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-12.m @@ -0,0 +1,51 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with a class methods */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +static int class_variable = 0; + +@interface SubClass : RootClass ++ (void) setState: (int)number; ++ (int) state; +@end + +@implementation SubClass ++ (void) setState: (int)number +{ + class_variable = number; +} ++ (int) state +{ + return class_variable; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class +#include "class-tests-2.h" + +int main (void) +{ + Class class; + + test_class_with_superclass ("SubClass", "RootClass"); + test_that_class_has_class_method ("SubClass", @selector (setState:)); + test_that_class_has_class_method ("SubClass", @selector (state)); + + class = objc_getClass ("SubClass"); + test_accessor_method (class, 0, -1, -1, 1, 1); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-13.m b/gcc-4.9/gcc/testsuite/objc/execute/class-13.m new file mode 100644 index 000000000..1d685e3a7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-13.m @@ -0,0 +1,72 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with a class accessor + methods and a subclass overriding the superclass' implementation + but reusing it with super */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +static int class_variable = 0; + +@interface SubClass : RootClass ++ (void) setState: (int)number; ++ (int) state; +@end + +@implementation SubClass ++ (void) setState: (int)number +{ + class_variable = number; +} ++ (int) state +{ + return class_variable; +} +@end + +@interface SubSubClass : SubClass +@end + +@implementation SubSubClass ++ (int) state +{ + return [super state] + 1; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class +#include "class-tests-2.h" + +int main (void) +{ + Class class; + Class sub_class; + + test_class_with_superclass ("SubClass", "RootClass"); + test_that_class_has_class_method ("SubClass", @selector (setState:)); + test_that_class_has_class_method ("SubClass", @selector (state)); + + test_class_with_superclass ("SubSubClass", "SubClass"); + test_that_class_has_class_method ("SubSubClass", @selector (setState:)); + test_that_class_has_class_method ("SubSubClass", @selector (state)); + + class = objc_getClass ("SubClass"); + test_accessor_method (class, 0, -1, -1, 1, 1); + + sub_class = objc_getClass ("SubSubClass"); + class_variable = 0; + test_accessor_method (sub_class, 1, -1, 0, 1, 2); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-14.m b/gcc-4.9/gcc/testsuite/objc/execute/class-14.m new file mode 100644 index 000000000..3ab0982c6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-14.m @@ -0,0 +1,77 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with a class accessor + methods and a subclass overriding the superclass' implementation, + and using self to call another method of itself */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +static int class_variable = 0; + +@interface SubClass : RootClass ++ (void) setState: (int)number; ++ (int) state; +@end + +@implementation SubClass ++ (void) setState: (int)number +{ + class_variable = number; +} ++ (int) state +{ + return class_variable; +} +@end + +@interface SubSubClass : SubClass ++ (int) shift; +@end + +@implementation SubSubClass ++ (int) state +{ + return class_variable + [self shift]; +} ++ (int) shift +{ + return 1; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class +#include "class-tests-2.h" + +int main (void) +{ + Class class, sub_class; + + test_class_with_superclass ("SubClass", "RootClass"); + test_that_class_has_class_method ("SubClass", @selector (setState:)); + test_that_class_has_class_method ("SubClass", @selector (state)); + + test_class_with_superclass ("SubSubClass", "SubClass"); + test_that_class_has_class_method ("SubSubClass", @selector (setState:)); + test_that_class_has_class_method ("SubSubClass", @selector (state)); + test_that_class_has_class_method ("SubSubClass", @selector (shift)); + + class = objc_getClass ("SubClass"); + test_accessor_method (class, 0, -1, -1, 1, 1); + + sub_class = objc_getClass ("SubSubClass"); + class_variable = 0; + test_accessor_method (sub_class, 1, -1, 0, 1, 2); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-2.m b/gcc-4.9/gcc/testsuite/objc/execute/class-2.m new file mode 100644 index 000000000..88378e1d4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-2.m @@ -0,0 +1,29 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass +@end + +@interface SubClass : RootClass +@end + +@implementation SubClass +@end + +#include "class-tests-1.h" + +int main (void) +{ + test_class_with_superclass ("SubClass", "RootClass"); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-3.m b/gcc-4.9/gcc/testsuite/objc/execute/class-3.m new file mode 100644 index 000000000..071708a6e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-3.m @@ -0,0 +1,43 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a minimal subclass tree */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass +@end + +@interface SubClassA : RootClass +@end + +@implementation SubClassA +@end + +@interface SubClassB : RootClass +@end + +@implementation SubClassB +@end + +@interface SubSubClass : SubClassA +@end + +@implementation SubSubClass +@end + +#include "class-tests-1.h" + +int main (void) +{ + test_class_with_superclass ("SubClassA", "RootClass"); + test_class_with_superclass ("SubClassB", "RootClass"); + test_class_with_superclass ("SubSubClass", "SubClassA"); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-4.m b/gcc-4.9/gcc/testsuite/objc/execute/class-4.m new file mode 100644 index 000000000..a86219163 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-4.m @@ -0,0 +1,53 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with an ivar and + accessor methods */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +@interface SubClass : RootClass +{ + int state; +} +- (void) setState: (int)number; +- (int) state; +@end + +@implementation SubClass +- (void) setState: (int)number +{ + state = number; +} +- (int) state +{ + return state; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass * +#include "class-tests-2.h" + +int main (void) +{ + SubClass *object; + + test_class_with_superclass ("SubClass", "RootClass"); + test_that_class_has_instance_method ("SubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubClass", @selector (state)); + + object = class_createInstance (objc_getClass ("SubClass"), 0); + test_accessor_method (object, 0, 1, 1, -3, -3); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-5.m b/gcc-4.9/gcc/testsuite/objc/execute/class-5.m new file mode 100644 index 000000000..d0dc97a5b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-5.m @@ -0,0 +1,72 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with an ivar and + accessor methods and a subclass overriding the superclass' + implementation */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +@interface SubClass : RootClass +{ + int state; +} +- (void) setState: (int)number; +- (int) state; +@end + +@implementation SubClass +- (void) setState: (int)number +{ + state = number; +} +- (int) state +{ + return state; +} +@end + +@interface SubSubClass : SubClass +@end + +@implementation SubSubClass +- (int) state +{ + return state + 1; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass * +#include "class-tests-2.h" + +int main (void) +{ + SubClass *object; + SubSubClass *sub_object; + + test_class_with_superclass ("SubClass", "RootClass"); + test_that_class_has_instance_method ("SubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubClass", @selector (state)); + + test_class_with_superclass ("SubSubClass", "SubClass"); + test_that_class_has_instance_method ("SubSubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubSubClass", @selector (state)); + + object = class_createInstance (objc_getClass ("SubClass"), 0); + test_accessor_method (object, 0, -1, -1, 1, 1); + + sub_object = class_createInstance (objc_getClass ("SubSubClass"), 0); + test_accessor_method (sub_object, 1, -1, 0, 1, 2); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-6.m b/gcc-4.9/gcc/testsuite/objc/execute/class-6.m new file mode 100644 index 000000000..e178f6193 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-6.m @@ -0,0 +1,72 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with an ivar and + accessor methods and a subclass overriding the superclass' + implementation but reusing it with super */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +@interface SubClass : RootClass +{ + int state; +} +- (void) setState: (int)number; +- (int) state; +@end + +@implementation SubClass +- (void) setState: (int)number +{ + state = number; +} +- (int) state +{ + return state; +} +@end + +@interface SubSubClass : SubClass +@end + +@implementation SubSubClass +- (int) state +{ + return [super state] + 1; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass * +#include "class-tests-2.h" + +int main (void) +{ + SubClass *object; + SubSubClass *sub_object; + + test_class_with_superclass ("SubClass", "RootClass"); + test_that_class_has_instance_method ("SubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubClass", @selector (state)); + + test_class_with_superclass ("SubSubClass", "SubClass"); + test_that_class_has_instance_method ("SubSubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubSubClass", @selector (state)); + + object = class_createInstance (objc_getClass ("SubClass"), 0); + test_accessor_method (object, 0, -1, -1, 1, 1); + + sub_object = class_createInstance (objc_getClass ("SubSubClass"), 0); + test_accessor_method (sub_object, 1, -1, 0, 1, 2); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-7.m b/gcc-4.9/gcc/testsuite/objc/execute/class-7.m new file mode 100644 index 000000000..31e240945 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-7.m @@ -0,0 +1,67 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with an ivar and + accessor methods; accessor methods implemented in a separate + category */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +@interface SubClass : RootClass +{ + int state; +} +@end + +@implementation SubClass +@end + +@interface SubClass (Additions) +- (void) setState: (int)number; +- (int) state; +@end + +@implementation SubClass (Additions) +- (void) setState: (int)number +{ + state = number; +} +- (int) state +{ + return state; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass * +#include "class-tests-2.h" + +int main (void) +{ + SubClass *object; + + test_class_with_superclass ("SubClass", "RootClass"); + + /* The NeXT runtime's category implementation is lazy: categories are not attached + to classes until the class is initialized (at +initialize time). */ +#ifdef __NEXT_RUNTIME__ + [SubClass initialize]; +#endif + + test_that_class_has_instance_method ("SubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubClass", @selector (state)); + + object = class_createInstance (objc_getClass ("SubClass"), 0); + test_accessor_method (object, 0, 1, 1, -3, -3); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-8.m b/gcc-4.9/gcc/testsuite/objc/execute/class-8.m new file mode 100644 index 000000000..ef4c2a3c8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-8.m @@ -0,0 +1,75 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with an ivar and + accessor methods and a subclass overriding the superclass' + implementation - in a category */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +@interface SubClass : RootClass +{ + int state; +} +- (void) setState: (int)number; +- (int) state; +@end + +@implementation SubClass +- (void) setState: (int)number +{ + state = number; +} +- (int) state +{ + return state; +} +@end + +@interface SubSubClass : SubClass +@end + +@implementation SubSubClass +@end + +@implementation SubSubClass (Additions) +- (int) state +{ + return state + 1; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass * +#include "class-tests-2.h" + +int main (void) +{ + SubClass *object; + SubSubClass *sub_object; + + test_class_with_superclass ("SubClass", "RootClass"); + test_that_class_has_instance_method ("SubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubClass", @selector (state)); + + test_class_with_superclass ("SubSubClass", "SubClass"); + test_that_class_has_instance_method ("SubSubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubSubClass", @selector (state)); + + object = class_createInstance (objc_getClass ("SubClass"), 0); + test_accessor_method (object, 0, -1, -1, 1, 1); + + sub_object = class_createInstance (objc_getClass ("SubSubClass"), 0); + test_accessor_method (sub_object, 1, -1, 0, 1, 2); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-9.m b/gcc-4.9/gcc/testsuite/objc/execute/class-9.m new file mode 100644 index 000000000..d27d34538 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-9.m @@ -0,0 +1,75 @@ +/* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */ + +#include + +/* Tests creating a root class and a subclass with an ivar and + accessor methods and a subclass overriding the superclass' + implementation but reusing it with super - in a category */ + +@interface RootClass +{ + Class isa; +} +@end + +@implementation RootClass ++ initialize { return self; } +@end + +@interface SubClass : RootClass +{ + int state; +} +- (void) setState: (int)number; +- (int) state; +@end + +@implementation SubClass +- (void) setState: (int)number +{ + state = number; +} +- (int) state +{ + return state; +} +@end + +@interface SubSubClass : SubClass +@end + +@implementation SubSubClass +@end + +@implementation SubSubClass (Additions) +- (int) state +{ + return [super state] + 1; +} +@end + +#include "class-tests-1.h" +#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass * +#include "class-tests-2.h" + +int main (void) +{ + SubClass *object; + SubSubClass *sub_object; + + test_class_with_superclass ("SubClass", "RootClass"); + test_that_class_has_instance_method ("SubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubClass", @selector (state)); + + test_class_with_superclass ("SubSubClass", "SubClass"); + test_that_class_has_instance_method ("SubSubClass", @selector (setState:)); + test_that_class_has_instance_method ("SubSubClass", @selector (state)); + + object = class_createInstance (objc_getClass ("SubClass"), 0); + test_accessor_method (object, 0, -1, -1, 1, 1); + + sub_object = class_createInstance (objc_getClass ("SubSubClass"), 0); + test_accessor_method (sub_object, 1, -1, 0, 1, 2); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-tests-1.h b/gcc-4.9/gcc/testsuite/objc/execute/class-tests-1.h new file mode 100644 index 000000000..cfdd72b47 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-tests-1.h @@ -0,0 +1,114 @@ +/* Contributed by Nicola Pero on Tue Mar 6 23:05:53 CET 2001 */ + +#include +#include +#include "../../objc-obj-c++-shared/runtime.h" + +/* + * Standard Tests For Classes and Objects - abort upon failing; return + * normally if all is well. + */ + +/* Test that `class' is a Class */ +static void test_is_class (Class class) +{ + if (class_isMetaClass (object_getClass (class)) == NO) + { + printf ("test_is_class failed\n"); + abort (); + } +} + +/* Test that the superclass of `class' is `superclass' */ +static void test_superclass (Class class, Class superclass) +{ + if (class_getSuperclass (class) != superclass) + { + printf ("test_superclass failed\n"); + abort (); + } +} + +/* Test that the classname of `class' is `classname' */ +static void test_class_name (Class class, const char *classname) +{ + if (strcmp (class_getName (class), classname)) + { + printf ("test_class_name failed\n"); + abort (); + } +} + +/* Test that we can allocate instances of `class' */ +static void test_allocate (Class class) +{ + /* The object we create is leaked but who cares, this is only a test */ + id object = class_createInstance (class, 0); + + if (object == nil) + { + printf ("test_allocate failed\n"); + abort (); + } +} + +/* Test that instances of `class' are instances and not classes */ +static void test_instances (Class class) +{ + id object = class_createInstance (class, 0); + + if (class_isMetaClass (object_getClass (object)) == YES) + { + printf ("test_instances failed\n"); + abort (); + } +} + +/* Test that we can deallocate instances of `class' */ +static void test_deallocate (Class class) +{ + id object = class_createInstance (class, 0); + + object_dispose (object); +} + +/* Test that the object and the class agree on what the class is */ +static void test_object_class (Class class) +{ + id object = class_createInstance (class, 0); + + if (object_getClass (object) != class) + { + printf ("test_object_class failed\n"); + abort (); + } +} + +/* + * Runs all the tests in this file for the specified class + */ +void test_class_with_superclass (const char *class_name, + const char *superclass_name) +{ + Class class; + Class superclass; + + /* class_name must be an existing class */ + class = objc_getClass (class_name); + test_is_class (class); + + /* But superclass_name can be "", which means `Nil' */ + superclass = objc_getClass (superclass_name); + if (superclass != Nil) + { + test_is_class (superclass); + } + + /* Now the tests */ + test_superclass (class, superclass); + test_class_name (class, class_name); + test_allocate (class); + test_instances (class); + test_deallocate (class); + test_object_class (class); +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class-tests-2.h b/gcc-4.9/gcc/testsuite/objc/execute/class-tests-2.h new file mode 100644 index 000000000..7f6f54000 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class-tests-2.h @@ -0,0 +1,67 @@ +/* Contributed by Nicola Pero on Tue Mar 6 23:05:53 CET 2001 */ +#include +#include +#include "../../objc-obj-c++-shared/runtime.h" + +/* + * Standard Tests For Methods of Classes and Objects - abort upon + * failing; return normally if all is well. + */ + +/* Test that `class' has an instance method for the selector `selector' */ +void test_that_class_has_instance_method (const char *class_name, + SEL selector) +{ + Class class = objc_getClass (class_name); + + if (class_getInstanceMethod (class, selector) == NULL) + { + printf ("test_class_has_instance_method failed\n"); + abort (); + } +} + +/* Test that `class' has a class method for the selector `selector' */ +void test_that_class_has_class_method (const char *class_name, + SEL selector) +{ + Class class = objc_getClass (class_name); + + if (class_getClassMethod (class, selector) == NULL) + { + printf ("test_class_has_class_method failed\n"); + abort (); + } +} + +/* Test the accessor methods (called -state and -setState:) on the + object `object'. */ +#ifdef TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD +void test_accessor_method (TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD object, + int initial_state, + int new_state_0, int expected_result_0, + int new_state_1, int expected_result_1) +{ + if ([object state] != initial_state) + { + printf ("test_accessor_method (initial state) failed\n"); + abort (); + } + + [object setState: new_state_0]; + if ([object state] != expected_result_0) + { + printf ("test_accessor_method (new_state_0) failed\n"); + abort (); + } + + [object setState: new_state_1]; + if ([object state] != expected_result_1) + { + printf ("test_accessor_method (new_state_1) failed\n"); + abort (); + } +} +#endif /* CLASS_WITH_ACCESSOR_METHOD */ + + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class_self-1.m b/gcc-4.9/gcc/testsuite/objc/execute/class_self-1.m new file mode 100644 index 000000000..9045305e5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class_self-1.m @@ -0,0 +1,63 @@ +/* Contributed by Nicola Pero - Fri Oct 26 22:39:32 BST 2001 */ +#include + +/* Test calling a class method when there is an instance method + with conflicting types */ + +/* This class should be unused but on broken compilers its instance + method might get picked up and used instead of the class method of + another class ! */ +struct d +{ + int a; +}; + +@interface UnusedClass +{ + Class isa; +} +- (struct d) method; +@end + +@implementation UnusedClass +- (struct d) method +{ + struct d u; + u.a = 0; + + return u; +} +@end + +/* The real class */ +@interface TestClass +{ + Class isa; +} ++ (void) test; ++ (int) method; +@end + +@implementation TestClass ++ (void) test +{ + if ([self method] != 4) + { + abort (); + } +} + ++ (int) method +{ + return 4; +} ++ initialize { return self; } +@end + + +int main (void) +{ + [TestClass test]; + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/class_self-2.m b/gcc-4.9/gcc/testsuite/objc/execute/class_self-2.m new file mode 100644 index 000000000..070c4c1a5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/class_self-2.m @@ -0,0 +1,68 @@ +/* Contributed by Nicola Pero - Fri Oct 26 22:39:32 BST 2001 */ +#include +#include + +/* Test calling a class method on self where self has been redefined + to be another class - the call requires a cast */ + + +/* The first class */ +struct d +{ + int a; +}; + +@interface ClassA +{ + Class isa; +} ++ (Class) class; ++ (struct d) method; +@end + +@implementation ClassA ++ (Class) class +{ + return self; +} + ++ (struct d) method +{ + struct d u; + u.a = 5; + + return u; +} ++ initialize { return self; } +@end + +/* The second class */ +@interface TestClass +{ + Class isa; +} ++ (void) test; +@end + +@implementation TestClass ++ (void) test +{ + self = [ClassA class]; + + + if ([(Class)self method].a != 5) + { + abort (); + } +} + ++ initialize { return self; } +@end + + +int main (void) +{ + [TestClass test]; + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/compatibility_alias.m b/gcc-4.9/gcc/testsuite/objc/execute/compatibility_alias.m new file mode 100644 index 000000000..8009a03d8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/compatibility_alias.m @@ -0,0 +1,12 @@ +/* Contributed by Nicola Pero - Thu Mar 8 17:23:59 CET 2001 */ +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +@compatibility_alias MyObject TestsuiteObject; + +int main (void) +{ + MyObject *object = [MyObject alloc]; + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/encode-1.m b/gcc-4.9/gcc/testsuite/objc/execute/encode-1.m new file mode 100644 index 000000000..4c4f2babf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/encode-1.m @@ -0,0 +1,31 @@ +/* Contributed by Nicola Pero - Thu Mar 8 16:27:46 CET 2001 */ +#include +#import "../../objc-obj-c++-shared/TestsuiteObject.h" +#include + +/* Test very simple @encode */ + +int main (void) +{ + if (strcmp ("i", @encode (int))) + { + abort (); + } + + if (strcmp ("@", @encode (id))) + { + abort (); + } + + if (strcmp ("@", @encode (TestsuiteObject *))) + { + abort (); + } + + if (strcmp (":", @encode (SEL))) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/enumeration-1.m b/gcc-4.9/gcc/testsuite/objc/execute/enumeration-1.m new file mode 100644 index 000000000..c380291b5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/enumeration-1.m @@ -0,0 +1,50 @@ +/* Contributed by Nicola Pero - Wed Dec 5 17:12:40 GMT 2001 */ +#include +#import "../../objc-obj-c++-shared/TestsuiteObject.m" + +/* Test using a bitfield enumeration ivar. */ + +typedef enum +{ + black, + white +} color; + +@interface TestClass: TestsuiteObject +{ + 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-4.9/gcc/testsuite/objc/execute/enumeration-2.m b/gcc-4.9/gcc/testsuite/objc/execute/enumeration-2.m new file mode 100644 index 000000000..3ce0504ff --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/enumeration-2.m @@ -0,0 +1,52 @@ +/* Contributed by Nicola Pero - Wed Dec 5 17:12:40 GMT 2001 */ +#include +#import "../../objc-obj-c++-shared/TestsuiteObject.m" + +typedef enum { black, white } color; + +typedef struct +{ + color a:2; + color b:2; +} color_couple; + +@interface TestClass: TestsuiteObject +{ + 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; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/exceptions/catchall-1.m b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/catchall-1.m new file mode 100644 index 000000000..ea8ef3993 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/catchall-1.m @@ -0,0 +1,77 @@ +/* Test out '@catch(id foo) {...}', which should catch all uncaught + exceptions. */ +/* Developed by Ziemowit Laski . */ + +#include +#include +#include "../../../objc-obj-c++-shared/TestsuiteObject.m" + +/* The following is not required in actual user code; we include it + here to check that the compiler generates an internal definition of + _setjmp that is consistent with what provides. */ +#include + +#define CHECK_IF(expr) if(!(expr)) abort() + +@interface Frob: TestsuiteObject +@end + +@implementation Frob: TestsuiteObject +@end + +static Frob* _connection = nil; + +//-------------------------------------------------------------------- + + +void test (TestsuiteObject* sendPort) +{ + int cleanupPorts = 1; + Frob* receivePort = nil; + + @try { + printf ("receivePort = %p\n", receivePort); + printf ("sendPort = %p\n", sendPort); + printf ("cleanupPorts = %d\n", cleanupPorts); + printf ("---\n"); + + receivePort = (Frob *) -1; + _connection = (Frob *) -1; + printf ("receivePort = %p\n", receivePort); + printf ("sendPort = %p\n", sendPort); + printf ("cleanupPorts = %d\n", cleanupPorts); + printf ("---\n"); + + receivePort = nil; + sendPort = nil; + cleanupPorts = 0; + + printf ("receivePort = %p\n", receivePort); + printf ("sendPort = %p\n", sendPort); + printf ("cleanupPorts = %d\n", cleanupPorts); + printf ("---\n"); + + @throw [TestsuiteObject new]; + } + @catch(Frob *obj) { + printf ("Exception caught by incorrect handler!\n"); + CHECK_IF(0); + } + @catch(id exc) { + printf ("Exception caught by correct handler.\n"); + printf ("receivePort = %p (expected 0x0)\n", receivePort); + printf ("sendPort = %p (expected 0x0)\n", sendPort); + printf ("cleanupPorts = %d (expected 0)\n", cleanupPorts); + printf ("---"); + CHECK_IF(!receivePort); + CHECK_IF(!sendPort); + CHECK_IF(!cleanupPorts); + } +} + +int main (void) { + + test((TestsuiteObject *)-1); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/exceptions/exceptions.exp b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/exceptions.exp new file mode 100644 index 000000000..1c60ce7d5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/exceptions.exp @@ -0,0 +1,49 @@ +# Copyright (C) 1991-2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# This file was written by Rob Savoye. (rob@cygnus.com) +# Modified by Ovidiu Predescu (ovidiu@aracnet.com) + + +if $tracelevel then { + strace $tracelevel +} + +set additional_flags "" +lappend additional_flags "-fobjc-exceptions" +# load support procs +load_lib objc-torture.exp +load_lib torture-options.exp +load_lib target-supports.exp + +torture-init +objc-set-runtime-options "execute" "additional_flags=-fobjc-exceptions" +set-torture-options $OBJC_TORTURE_OPTIONS $OBJC_RUNTIME_OPTIONS + +# +# main test loop +# + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.m]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + objc-torture-execute $src $additional_flags +} + +torture-finish diff --git a/gcc-4.9/gcc/testsuite/objc/execute/exceptions/finally-1.m b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/finally-1.m new file mode 100644 index 000000000..30ec7b2d1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/finally-1.m @@ -0,0 +1,60 @@ +#include +#include +#include "../../../objc-obj-c++-shared/TestsuiteObject.m" + +static int made_try = 0; + +int +thrower_try_body() +{ + made_try++; + return (0); +} + +static int made_finally = 0; + +int +finally_body() +{ + made_finally++; + return (0); +} + +int +thrower() +{ + @try + { + thrower_try_body(); + @throw [TestsuiteObject new]; + } + @finally + { + finally_body(); + } + return 0; +} + +static int made_catch = 0; + +int +main(int ac, char *av[]) +{ + @try + { + thrower(); + } + @catch (id exc) + { + made_catch++; + [exc free]; + } + if (made_try != 1) + abort (); + if (made_finally != 1) + abort (); + if (made_catch != 1) + abort (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/exceptions/foward-1.m b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/foward-1.m new file mode 100644 index 000000000..5738b225e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/foward-1.m @@ -0,0 +1,42 @@ +/* Check that throwing an exception from a -forward:: works. */ +/* Developed by Marcin Koziej . */ + +#include +#include +#include "../../../objc-obj-c++-shared/TestsuiteObject.m" + +static int i; + +__attribute__((objc_exception)) +@interface Thrower : TestsuiteObject +- forward: (SEL) s : (void*) a; +@end + +@implementation Thrower +- forward: (SEL) s : (void*) a +{ + i++; + @throw [TestsuiteObject new]; + return nil; +} +@end + +int +main() +{ + id t = [Thrower new]; + @try + { + [t doesnotexist]; + } + @catch (id error) + { + i++; + [error free]; + } + + if (i != 2) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/exceptions/foward-1.x b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/foward-1.x new file mode 100644 index 000000000..9acd2737a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/foward-1.x @@ -0,0 +1,11 @@ +# XFAIL the run for m64 Darwin NeXT (seems to be a system runtime lib problem). +if { [istarget *-*-darwin*] && [check_effective_target_lp64] } { + set torture_eval_before_execute { + global compiler_conditional_xfail_data + set compiler_conditional_xfail_data { + "Target fails for fnext-runtime" "*-*-*" { "-fnext-runtime" } { "" } + } + } +} +# carry on... +return false diff --git a/gcc-4.9/gcc/testsuite/objc/execute/exceptions/handler-1.m b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/handler-1.m new file mode 100644 index 000000000..2127f44e2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/handler-1.m @@ -0,0 +1,53 @@ +/* Test custom exception handlers */ +/* Author: David Ayers */ + +#ifdef __NEXT_RUNTIME__ +/* This test only runs for the GNU runtime. TODO: It should work on + the NEXT runtime as well (needs testing). + */ + +int main(void) +{ + return 0; +} + +#else + +#include +#include +#include "../../../objc-obj-c++-shared/TestsuiteObject.m" +#include + +static unsigned int handlerExpected = 0; + +void +my_exception_handler(id excp) +{ + /* Returning from the handler would abort. */ + if (handlerExpected) + exit(0); + + abort(); +} + +int +main(int argc, char *argv[]) +{ + objc_setUncaughtExceptionHandler (my_exception_handler); + + @try + { + @throw [TestsuiteObject new]; + } + @catch (id exc) + { + handlerExpected = 1; + } + + @throw [TestsuiteObject new]; + abort(); + return 0; +} + + +#endif diff --git a/gcc-4.9/gcc/testsuite/objc/execute/exceptions/local-variables-1.m b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/local-variables-1.m new file mode 100644 index 000000000..700df9760 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/local-variables-1.m @@ -0,0 +1,63 @@ +/* Check that local variables that get modified inside the @try + block survive until the @catch block is reached. */ +/* Developed by Ziemowit Laski . */ + +#include +#include +#import "../../../objc-obj-c++-shared/TestsuiteObject.m" + +int gi1 = 9, gi2 = 19; +float gf1 = 9.0, gf2 = 19.0; +id obj2 = nil; + +void foo (int arg1, float *arg2) +{ + int *pi = &gi1; + float *pf = &gf1; + id obj1 = nil; + int local1 = 45, local2 = 47; + float local3 = 3.0, local4 = 4.0; + register int local5 = 15; + static float local6 = 16.0; + + @try { + local1 = 123; + local2 = 345; + local3 = 5.0; + local4 = 6.0; + local5 = 17; + local6 = 18.0; + pi = &gi2; + pf = &gf2; + obj2 = obj1 = [TestsuiteObject new]; + arg1 = 17; + arg2 = &gf2; + + @throw [TestsuiteObject new]; + } + @catch (TestsuiteObject *obj) { + if (local1 != 123 || local2 != 345 || local3 != 5.0 || local4 != 6.0 + || local5 != 17 || local6 != 18.0) { + printf("Abort 1\n"); + abort(); + } + if(pi != &gi2 || pf != &gf2) { + printf("Abort 2\n"); + abort(); + } + if(!obj1 || obj1 != obj2) { + printf("Abort 3\n"); + abort(); + } + if(arg1 != 17 || arg2 != &gf2) { + printf("Abort 4\n"); + abort(); + } + } +} + +int main(void) { + foo(15, &gf1); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/exceptions/matcher-1.m b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/matcher-1.m new file mode 100644 index 000000000..cbe4365da --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/matcher-1.m @@ -0,0 +1,68 @@ +/* Test custom exception matchers */ +/* Author: Nicola Pero */ + +#ifdef __NEXT_RUNTIME__ +/* This test only runs for the GNU runtime. TODO: It should work on + the NEXT runtime as well (needs testing). + */ + +int main(void) +{ + return 0; +} + +#else + +#include +#include +#include "../../../objc-obj-c++-shared/TestsuiteObject.m" +#include + +static unsigned int handlerExpected = 0; + +void +my_exception_matcher(Class match_class, id exception) +{ + /* Always matches. */ + return 1; +} + +@interface A : TestsuiteObject +@end + +@implementation A +@end + +@interface B : TestsuiteObject +@end + +@implementation B +@end + +int +main(int argc, char *argv[]) +{ + objc_setExceptionMatcher (my_exception_matcher); + + @try + { + @throw [A new]; + } + @catch (B *exception) + { + /* Since we installed an exception matcher that always matches, + the exception should be sent here even if it's of class A and + this is looking for exceptions of class B. + */ + return 0; + } + @catch (id exception) + { + abort (); + } + + abort (); +} + + +#endif diff --git a/gcc-4.9/gcc/testsuite/objc/execute/exceptions/pr31281.m b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/pr31281.m new file mode 100644 index 000000000..41e7a8e16 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/pr31281.m @@ -0,0 +1,27 @@ +/* From PR31281. */ +extern void abort (void); +int __attribute__((noinline)) +f(unsigned int i) +{ + int j, k; + @try { } @catch(id) { return 13; } + for (j=0; j +#include "../../../objc-obj-c++-shared/TestsuiteObject.m" + +#ifdef __NEXT_RUNTIME__ +/* This test only runs for the GNU runtime. */ + +int main(void) +{ + return 0; +} + +#else + +/* Test throwing a nil exception. A 'nil' exception can only be + caugth by a generic exception handler. + */ + +int main (void) +{ + int exception_catched = 0; + int finally_called = 0; + + @try + { + @throw nil; + } + @catch (TestsuiteObject *exc) + { + abort (); + } + @catch (id exc) + { + exception_catched = 1; + } + @finally + { + finally_called = 1; + } + + + if (exception_catched != 1 + || finally_called != 1) + { + abort (); + } + + return 0; +} + +#endif diff --git a/gcc-4.9/gcc/testsuite/objc/execute/exceptions/trivial.m b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/trivial.m new file mode 100644 index 000000000..d218183f3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/exceptions/trivial.m @@ -0,0 +1,17 @@ +#include +#include "../../../objc-obj-c++-shared/TestsuiteObject.m" + +/* do nothing except prove we can compile and link code calling the + ecceptions mechanism */ + +int main(void) +{ + @try { + int a = 1 ; + @throw [TestsuiteObject new]; + } + @catch (TestsuiteObject *obj) { + return 0; + } + abort(); +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/execute.exp b/gcc-4.9/gcc/testsuite/objc/execute/execute.exp new file mode 100644 index 000000000..320be125c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/execute.exp @@ -0,0 +1,46 @@ +# Copyright (C) 1991-2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# This file was written by Rob Savoye. (rob@cygnus.com) +# Modified by Ovidiu Predescu (ovidiu@aracnet.com) + + +if $tracelevel then { + strace $tracelevel +} + +# load support procs +load_lib objc-torture.exp +load_lib torture-options.exp + +torture-init +objc-set-runtime-options "execute" +set-torture-options $OBJC_TORTURE_OPTIONS $OBJC_RUNTIME_OPTIONS + +# +# main test loop +# + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.m]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + objc-torture-execute $src +} + +torture-finish diff --git a/gcc-4.9/gcc/testsuite/objc/execute/fdecl.m b/gcc-4.9/gcc/testsuite/objc/execute/fdecl.m new file mode 100644 index 000000000..807be0381 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/fdecl.m @@ -0,0 +1,19 @@ +/* Bug report submitted by igorkh@hotbot.com on submit@bugs.debian.org + Thu, 13 Apr 2000 09:42:08 -0400 */ + +@class AClass; + +@interface test +{ + AClass *foo; +} +@end + +@implementation test +@end + +int main (void) +{ + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-1.m b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-1.m new file mode 100644 index 000000000..f0b585387 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-1.m @@ -0,0 +1,45 @@ +/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */ + +#include +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +/* Tests defining a protocol and a class adopting it */ + +@protocol Enabling +- (BOOL) isEnabled; +- (void) setEnabled: (BOOL)flag; +@end + +@interface Feature : TestsuiteObject +{ + const char *name; + BOOL isEnabled; +} +@end + +@implementation Feature +- (BOOL) isEnabled +{ + return isEnabled; +} +- (void) setEnabled: (BOOL)flag +{ + isEnabled = flag; +} +@end + +int main (void) +{ + Feature *object; + + object = [Feature new]; + + [object setEnabled: YES]; + if (![object isEnabled]) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-2.m b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-2.m new file mode 100644 index 000000000..e3c9db1fb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-2.m @@ -0,0 +1,46 @@ +/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */ + +#include +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +/* Test defining a protocol, a class adopting it, and using an object + of type `id '. */ + +@protocol Enabling +- (BOOL) isEnabled; +- (void) setEnabled: (BOOL)flag; +@end + +@interface Feature : TestsuiteObject +{ + const char *name; + BOOL isEnabled; +} +@end + +@implementation Feature +- (BOOL) isEnabled +{ + return isEnabled; +} +- (void) setEnabled: (BOOL)flag +{ + isEnabled = flag; +} +@end + +int main (void) +{ + id object; + + object = [Feature new]; + + [object setEnabled: YES]; + if (![object isEnabled]) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-3.m b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-3.m new file mode 100644 index 000000000..0339b9548 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-3.m @@ -0,0 +1,59 @@ +/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */ + +#include +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +/* Test defining two protocol, a class adopting both of them, + and using an object of type `id ' */ + +@protocol Enabling +- (BOOL) isEnabled; +- (void) setEnabled: (BOOL)flag; +@end + +@protocol Evaluating +- (int) importance; +@end + +@interface Feature : TestsuiteObject +{ + const char *name; + BOOL isEnabled; +} +@end + +@implementation Feature +- (BOOL) isEnabled +{ + return isEnabled; +} +- (void) setEnabled: (BOOL)flag +{ + isEnabled = flag; +} +- (int) importance +{ + return 1000; +} +@end + +int main (void) +{ + id object; + + object = [Feature new]; + + [object setEnabled: YES]; + if (![object isEnabled]) + { + abort (); + } + + if ([object importance] != 1000) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-4.m b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-4.m new file mode 100644 index 000000000..a416c4a0c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-4.m @@ -0,0 +1,41 @@ +/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */ + +#include +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +/* Test defining a protocol, a class adopting it in a category */ + +@protocol Evaluating +- (int) importance; +@end + +@interface Feature : TestsuiteObject +@end + +@implementation Feature +@end + +@interface Feature (EvaluatingProtocol) +@end + +@implementation Feature (EvaluatingProtocol) +- (int) importance +{ + return 1000; +} +@end + +int main (void) +{ + id object; + + object = [Feature new]; + + if ([object importance] != 1000) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-5.m b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-5.m new file mode 100644 index 000000000..73ec02f7e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-5.m @@ -0,0 +1,34 @@ +/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */ + +#include +#include +#include "../../objc-obj-c++-shared/runtime.h" + +/* Test defining a protocol, and accessing it using @protocol */ + +@protocol Evaluating +- (int) importance; +@end + +/* A class adopting the protocol */ +@interface Test +@end + +@implementation Test +- (int) importance +{ + return 1000; +} +@end + +int main (void) +{ + Protocol *protocol = @protocol (Evaluating); + + if (strcmp (protocol_getName(protocol), "Evaluating")) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-6.m b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-6.m new file mode 100644 index 000000000..667796327 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-6.m @@ -0,0 +1,27 @@ +/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */ + +#include +#include +#include "../../objc-obj-c++-shared/runtime.h" + +/* Test defining a protocol, and accessing it using @protocol */ + +@protocol Evaluating +- (int) importance; +@end + +/* Without a class adopting the protocol - this doesn't work + with gcc-2.95.2 as well */ + +int main (void) +{ + Protocol *protocol = @protocol (Evaluating); + + if (strcmp (protocol_getName(protocol), "Evaluating")) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-7.m b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-7.m new file mode 100644 index 000000000..9e9e730ff --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/formal_protocol-7.m @@ -0,0 +1,45 @@ +/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */ + +#include +#include +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +/* Test defining two protocols, one incorporating the other one. */ + +@protocol Configuring +- (void) configure; +@end + +@protocol Processing +- (void) process; +@end + +/* A class adopting the protocol */ +@interface Test : TestsuiteObject +{ + BOOL didConfigure; + BOOL didProcess; +} +@end + +@implementation Test +- (void) configure +{ + didConfigure = YES; +} +- (void) process +{ + didProcess = YES; +} +@end + +int main (void) +{ + id object = [Test new]; + + [object configure]; + [object process]; + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/function-message-1.m b/gcc-4.9/gcc/testsuite/objc/execute/function-message-1.m new file mode 100644 index 000000000..f676dd9a0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/function-message-1.m @@ -0,0 +1,33 @@ +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +@interface Foo : TestsuiteObject ++ bar; +@end + +int foocalled = 0; +int barcalled = 0; + + +id foo() +{ + if (foocalled) + abort (); + foocalled = 1; + return [Foo class]; +} + +@implementation Foo ++ bar +{ + if (barcalled) + abort (); + barcalled = 1; + return self; +} +@end + +int main(int argc,char **argv) +{ + [foo() bar]; + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/informal_protocol.m b/gcc-4.9/gcc/testsuite/objc/execute/informal_protocol.m new file mode 100644 index 000000000..e21a750ee --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/informal_protocol.m @@ -0,0 +1,13 @@ +/* Contributed by Nicola Pero - Fri Mar 9 21:35:47 CET 2001 */ +#import "../../objc-obj-c++-shared/TestsuiteObject.h" +#include + +@interface TestsuiteObject (StopProtocol) +- (void) stop; +@end + +int main (void) +{ + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m b/gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m new file mode 100644 index 000000000..9ca4aebbe --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/initialize-1.m @@ -0,0 +1,47 @@ +/* Contributed by Nicola Pero - Sat 8 Oct 2011 16:47:48 BST */ +#include + +/* Test that if a class has no +initialize method, the superclass + implementation is called. */ + +static int class_variable = 0; + +@interface TestClass +{ + Class isa; +} ++ (void) initialize; ++ (int) classVariable; +@end + +@implementation TestClass ++ (void) initialize +{ + class_variable++; +} ++ (int) classVariable +{ + return class_variable; +} +@end + +@interface TestSubClass : TestClass +@end + +@implementation TestSubClass +@end + +int main (void) +{ + if ([TestClass classVariable] != 1) + { + abort (); + } + + if ([TestSubClass classVariable] != 2) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/initialize.m b/gcc-4.9/gcc/testsuite/objc/execute/initialize.m new file mode 100644 index 000000000..537839829 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/initialize.m @@ -0,0 +1,36 @@ +/* Contributed by Nicola Pero - Wed Mar 7 17:55:04 CET 2001 */ +#include + +/* Test that +initialize is automatically called before the class is + accessed */ + +static int class_variable = 0; + +@interface TestClass +{ + Class isa; +} ++ (void) initialize; ++ (int) classVariable; +@end + +@implementation TestClass ++ (void) initialize +{ + class_variable = 1; +} ++ (int) classVariable +{ + return class_variable; +} +@end + +int main (void) +{ + if ([TestClass classVariable] != 1) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/load-2.m b/gcc-4.9/gcc/testsuite/objc/execute/load-2.m new file mode 100644 index 000000000..eb9065836 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/load-2.m @@ -0,0 +1,46 @@ +/* Contributed by Nicola Pero - Wed Jun 6 14:34:23 CEST 2001 */ +#include + +/* Test that +load is automatically called before main is run; + on two different classes. */ + +static int static_variable1 = 0; +static int static_variable2 = 0; + +@interface TestClass1 +{ + Class isa; +} ++ (void) load; +@end + +@implementation TestClass1 ++ (void) load +{ + static_variable1 = 1; +} +@end + +@interface TestClass2 +{ + Class isa; +} ++ (void) load; +@end + +@implementation TestClass2 ++ (void) load +{ + static_variable2 = 1; +} +@end + +int main (void) +{ + if (static_variable1 != 1 || static_variable2 != 1) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/load-3.m b/gcc-4.9/gcc/testsuite/objc/execute/load-3.m new file mode 100644 index 000000000..d27b3c97c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/load-3.m @@ -0,0 +1,109 @@ +/* + load-3.m + + Author: Ovidiu Predescu + Date: June 3, 2001 + + Test if the +load methods are invoked, and are invoked in the + proper order. + */ + +#include +#include "../../objc-obj-c++-shared/TestsuiteObject.m" +#include + +@interface A : TestsuiteObject +@end + +@interface B : A +@end + +static a_load = 0; +static b_load = 0; +static a_category_load = 0; +static b_category_load = 0; + +@implementation A (Category) ++ (void)load +{ + a_category_load = 1; + printf("+[A(Category) load]\n"); + + if (a_load != 1) + { + printf("+load for A(Category) invoked before A's!\n"); + abort(); + } +} +@end + +@implementation B(Category) ++ (void)load +{ + b_category_load = 1; + printf("+[B(Category) load]\n"); + + if (b_load != 1) + { + printf ("+load for B(Category) invoked before B!\n"); + abort(); + } +} +@end + +@implementation B ++ (void)load +{ + b_load = 1; + printf("+[B load]\n"); + + if (a_load != 1) + { + printf("+load for B invoked before A's!\n"); + abort(); + } + + if (b_category_load != 0) + { + printf("+load for B invoked after B(Category)!\n"); + abort(); + } +} +@end + +@implementation A ++ (void)load +{ + a_load = 1; + printf("+[A load]\n"); + + if (a_category_load != 0) + { + printf("+load for A(Category) invoked before A!\n"); + abort(); + } + + if (b_load != 0) + { + printf("+load for A invoked after B!\n"); + abort(); + } + + if (b_category_load != 0) + { + printf("+load for B(Category) invoked before A and B!\n"); + abort(); + } +} +@end + +int main (void) +{ + if (a_load + b_load + a_category_load + b_category_load != 4) + { + printf("Not all +load methods invoked!\n"); + abort(); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/load.m b/gcc-4.9/gcc/testsuite/objc/execute/load.m new file mode 100644 index 000000000..fad662384 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/load.m @@ -0,0 +1,30 @@ +/* Contributed by Nicola Pero - Wed Mar 7 17:55:04 CET 2001 */ +#include + +/* Test that +load is automatically called before main is run */ + +static int static_variable = 0; + +@interface TestClass +{ + Class isa; +} ++ (void) load; +@end + +@implementation TestClass ++ (void) load +{ + static_variable = 1; +} +@end + +int main (void) +{ + if (static_variable != 1) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/many_args_method.m b/gcc-4.9/gcc/testsuite/objc/execute/many_args_method.m new file mode 100644 index 000000000..0c2166945 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/many_args_method.m @@ -0,0 +1,57 @@ +/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */ +#include + +/* Test the syntax of methods with many arguments */ + +@interface TestClass +{ + Class isa; +} ++ (int) sumInteger: (int)a withInteger: (int)b; ++ (int) sum: (int)a : (int)b; ++ (int) sumInteger: (int)a withInteger: (int)b withInteger: (int)c; ++ (int) sum: (int)a : (int)b : (int)c; +@end + +@implementation TestClass ++ (int) sumInteger: (int)a withInteger: (int)b +{ + return a + b; +} ++ (int) sum: (int)a : (int)b +{ + return [self sumInteger: a withInteger: b]; +} ++ (int) sumInteger: (int)a withInteger: (int)b withInteger: (int)c +{ + return a + b + c; +} ++ (int) sum: (int)a : (int)b : (int)c +{ + return [self sumInteger: a withInteger: b withInteger: c]; +} ++ initialize { return self; } +@end + + +int main (void) +{ + if ([TestClass sumInteger: 1 withInteger: 1] != 2) + { + abort (); + } + if ([TestClass sum: 1 : 1] != 2) + { + abort (); + } + if ([TestClass sumInteger: 1 withInteger: 1 withInteger: 1] != 3) + { + abort (); + } + if ([TestClass sum: 1 : 1 : 1] != 3) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/nested-1.m b/gcc-4.9/gcc/testsuite/objc/execute/nested-1.m new file mode 100644 index 000000000..02a390368 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/nested-1.m @@ -0,0 +1,12 @@ +/* Contributed by Nicola Pero Wed Feb 21 12:08:16 GMT 2001 */ + +int main (void) +{ + void nested (void) + { + return; + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/nested-2.m b/gcc-4.9/gcc/testsuite/objc/execute/nested-2.m new file mode 100644 index 000000000..0c67ec147 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/nested-2.m @@ -0,0 +1,17 @@ +/* Contributed by Nicola Pero Mon Mar 5 19:57:11 CET 2001 */ + +int main (void) +{ + inline int nested (void) + { + return 1; + } + + if (nested () != 1) + { + exit (1); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/nested-3.m b/gcc-4.9/gcc/testsuite/objc/execute/nested-3.m new file mode 100644 index 000000000..1ca0c4836 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/nested-3.m @@ -0,0 +1,38 @@ +/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */ +#include + +/* Test defining a nested function inside a method */ + +@interface Test +{ + Class isa; +} ++ (int) test; +@end + +@implementation Test + ++ (int) test +{ + int test (void) + { + return 1; + } + + return test (); +} + ++ initialize { return self; } +@end + +int main (void) +{ + if ([Test test] != 1) + { + abort (); + } + + return 0; +} + + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/nested-func-1.m b/gcc-4.9/gcc/testsuite/objc/execute/nested-func-1.m new file mode 100644 index 000000000..fbe9e2524 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/nested-func-1.m @@ -0,0 +1,36 @@ +/* Test basic nested C function functionality within ObjC + methods. */ +/* Contributed by Ziemowit Laski . */ +#include +#include +#import "../../objc-obj-c++-shared/TestsuiteObject.m" +#include + +int bappy (int (*blargh) (int a, int b, int c)) +{ + return blargh (4, 7, 2) + 3; +} + +@interface Foo: TestsuiteObject ++ (int)foo; +@end + +@implementation Foo ++ (int)foo +{ + int blargh (int a, int b, int c) + { + return a * b + c; + } + return bappy (blargh); +} +@end + +int main () +{ + int f = [Foo foo]; + if (f != 33) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/nil_method-1.m b/gcc-4.9/gcc/testsuite/objc/execute/nil_method-1.m new file mode 100644 index 000000000..3835f2fec --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/nil_method-1.m @@ -0,0 +1,61 @@ +/* Contributed by Nicola Pero - Fri Aug 30 12:55:37 2002 */ +#include +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +/* Test that calling a method of a nil object results in + nothing to happen (but not a crash), and nil to be + returned. */ + +@interface TestClass : TestsuiteObject + +- (void) testVoid; +- (id) testId; + +- (void) testVoidWithA: (int)a; +- (id) testIdWithA: (id)a; + +- (void) testVoidWithA: (int)a andB: (int)b; +- (id) testIdWithA: (id)g andB: (id)b; + +- (void) voidSum: (int)firstNumber, ...; +- (id) sum: (int)firstNumber, ...; + +@end + +int main (void) +{ + TestClass *t = nil; + + [t testVoid]; + + if ([t testId] != nil) + { + abort (); + } + + [t testVoidWithA: 234]; + + if ([t testIdWithA: t] != nil) + { + abort (); + } + + [t testVoidWithA: 12004 andB: -123]; + + if ([t testIdWithA: t andB: nil] != nil) + { + abort (); + } + + + [t voidSum: 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, + 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]; + + if ([t sum: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] != nil) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/no_clash.m b/gcc-4.9/gcc/testsuite/objc/execute/no_clash.m new file mode 100644 index 000000000..5db6a57b8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/no_clash.m @@ -0,0 +1,42 @@ +/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */ +#include "../../objc-obj-c++-shared/TestsuiteObject.m" +#import + +/* Test that using the same name for different things makes no + problem */ + +@interface TestClass : TestsuiteObject +{ + int test; +} ++ (int) test; +- (int) test; +@end + +@implementation TestClass ++ (int) test +{ + return 1; +} +- (int) test +{ + /* 0 + 2 as `test' is implicitly initialized to zero */ + return test + 2; +} +@end + + +int main (void) +{ + if ([TestClass test] != 1) + { + abort (); + } + if ([[[TestClass alloc] init] test] != 2) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/np-1.m b/gcc-4.9/gcc/testsuite/objc/execute/np-1.m new file mode 100644 index 000000000..a14fcc3e6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/np-1.m @@ -0,0 +1,30 @@ +/* + * Contributed by Nicola Pero + * Tue Sep 19 4:29AM + */ + +#include + +@protocol MyProtocol +- (oneway void) methodA; +@end + +@interface MyObject +@end + +@implementation MyObject +- (oneway void) methodA +{ +} +@end + +int main (void) +{ + MyObject *object = nil; + + [object methodA]; + + return 0; +} + + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/np-2.m b/gcc-4.9/gcc/testsuite/objc/execute/np-2.m new file mode 100644 index 000000000..af973cf9d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/np-2.m @@ -0,0 +1,30 @@ +/* + * Contributed by Nicola Pero + * Tue Sep 19 4:34AM + */ + +#include + +@protocol MyProtocol ++ (oneway void) methodA; +@end + +@interface MyObject +@end + +@implementation MyObject ++ (oneway void) methodA +{ + printf ("methodA\n"); +} ++ initialize { return self; } +@end + +int main (void) +{ + [MyObject methodA]; + + return 0; +} + + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/object_is_class.m b/gcc-4.9/gcc/testsuite/objc/execute/object_is_class.m new file mode 100644 index 000000000..483c38712 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/object_is_class.m @@ -0,0 +1,42 @@ +/* Contributed by Nicola Pero - Tue Jul 3 10:55:21 BST 2001 */ + +#include "../../objc-obj-c++-shared/runtime.h" +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +/* This test demonstrate a failure in object_is_class which was fixed */ + +/* Create a class whose instance variables mirror the struct used for + Class structures in the runtime ... yes we're feeling evil today */ +@interface EvilClass : TestsuiteObject +{ + Class super_class; + const char* name; + long version; + unsigned long info; +} +@end + +@implementation EvilClass +- (id) init +{ + self = [super init]; + /* The following one is used in the runtime to mark classes */ + info = 0x1L; + return self; +} +@end + +int main (void) +{ + /* Create an object of our EvilClass */ + EvilClass *evilObject = [EvilClass new]; + + /* Now check that the object is not a class object */ + if (class_isMetaClass (object_getClass (evilObject))) + { + printf ("object_is_class failed\n"); + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/object_is_meta_class.m b/gcc-4.9/gcc/testsuite/objc/execute/object_is_meta_class.m new file mode 100644 index 000000000..217873f53 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/object_is_meta_class.m @@ -0,0 +1,42 @@ +/* Contributed by Nicola Pero - Tue Jul 3 10:55:21 BST 2001 */ + +#include "../../objc-obj-c++-shared/runtime.h" +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +/* This test demonstrate a failure in object_is_meta_class which was fixed */ + +@interface EvilClass : TestsuiteObject +{ + Class super_class; + const char* name; + long version; + unsigned long info; +} +@end + +@implementation EvilClass +- (id) init +{ + self = [super init]; + /* The following one is used in the runtime to mark meta classes */ + info = 0x2L; + return self; +} +@end + +int main (void) +{ + /* Create an object of our EvilClass */ + EvilClass *evilObject = [EvilClass new]; + + /* Now check that the object is not a meta class object */ + if (class_isMetaClass (object_getClass (evilObject)) + && class_isMetaClass (evilObject)) + { + printf ("object_is_meta_class failed\n"); + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/pr25328.m b/gcc-4.9/gcc/testsuite/objc/execute/pr25328.m new file mode 100644 index 000000000..7b8502353 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/pr25328.m @@ -0,0 +1,11 @@ +/* PR objc/25328 */ + +int +main () +{ + int status = 0; + char msg[100] = ""; + if (__builtin_strcmp (msg, "")) + status = 200; + return status; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/private.m b/gcc-4.9/gcc/testsuite/objc/execute/private.m new file mode 100644 index 000000000..c1959efe7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/private.m @@ -0,0 +1,32 @@ +/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */ +#import "../../objc-obj-c++-shared/TestsuiteObject.m" +#include + +/* Test the @private, @protected, @public keyworks for ivars. We only + check syntax. */ + +@interface TestClass : TestsuiteObject +{ + int a; + +@private + int ivarOne, ivarTwo; + id ivarThree; + +@protected + int ivarFour; + +@public + id ivarFive; +} +@end + +@implementation TestClass +@end + + +int main (void) +{ + /* Only test compilation */ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-1.m b/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-1.m new file mode 100644 index 000000000..b928337aa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-1.m @@ -0,0 +1,21 @@ +/* Contributed by Nicola Pero - Fri Jun 4 03:16:17 BST 2004 */ +/* Test that a protocol is equal to itself. */ +#include +#include "../../objc-obj-c++-shared/runtime.h" + +@protocol Foo +- (void)foo; +@end + +int main (void) +{ + Protocol *protocol = @protocol(Foo); + + if (!protocol_isEqual (protocol, protocol)) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-2.m b/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-2.m new file mode 100644 index 000000000..cc1357663 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-2.m @@ -0,0 +1,23 @@ +/* Contributed by Nicola Pero - Fri Jun 4 03:16:17 BST 2004 */ +/* Test that protocols with different names are different. */ +#include "../../objc-obj-c++-shared/runtime.h" +#include + +@protocol Foo1 +- (void)foo1; +@end + +@protocol Foo2 +- (void)foo2; +@end + +int main (void) +{ + if (protocol_isEqual (@protocol(Foo1), @protocol(Foo2))) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-3.m b/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-3.m new file mode 100644 index 000000000..70d450fd8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-3.m @@ -0,0 +1,19 @@ +/* Contributed by Nicola Pero - Fri Jun 4 03:16:17 BST 2004 */ +/* Test that a protocol is not equal to nil. */ +#include "../../objc-obj-c++-shared/runtime.h" +#include + +@protocol Foo +- (void)foo; +@end + +int main (void) +{ + if (protocol_isEqual (@protocol(Foo), nil)) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-4.m b/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-4.m new file mode 100644 index 000000000..3d14fb263 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/protocol-isEqual-4.m @@ -0,0 +1,20 @@ +/* Contributed by David Ayers - Fri Jun 4 03:16:17 BST 2004 */ +/* Test that a protocol is not equal to something which is not a protocol. */ +#include "../../objc-obj-c++-shared/runtime.h" +#include + +@protocol Foo +- (void)foo; +@end + +int main (void) +{ + /* A Protocol object should not be equal to a Class object. */ + if (protocol_isEqual (@protocol(Foo), (id)objc_getClass("Protocol"))) + { + abort (); + } + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/protocol.m b/gcc-4.9/gcc/testsuite/objc/execute/protocol.m new file mode 100644 index 000000000..539fc2994 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/protocol.m @@ -0,0 +1,21 @@ +@protocol Foo +- (void)foo; +@end + +@interface Foo_c +{ +} +- (void)foo; +@end + +@implementation Foo_c +- (void)foo +{ +} +@end + +int main (void) +{ + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/redefining_self.m b/gcc-4.9/gcc/testsuite/objc/execute/redefining_self.m new file mode 100644 index 000000000..f22ca927f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/redefining_self.m @@ -0,0 +1,32 @@ +/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */ +#include + +/* Test redefining self */ + +@interface TestClass +{ + Class isa; +} ++ (Class) class; +@end + +@implementation TestClass ++ (Class) class +{ + self = Nil; + + return self; +} ++ initialize { return self; } +@end + + +int main (void) +{ + if ([TestClass class] != Nil) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/root_methods.m b/gcc-4.9/gcc/testsuite/objc/execute/root_methods.m new file mode 100644 index 000000000..e75640ce7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/root_methods.m @@ -0,0 +1,45 @@ +/* Contributed by Nicola Pero - Thu Mar 8 16:27:46 CET 2001 */ + +#import "../../objc-obj-c++-shared/runtime.h" +#import + +/* Test that instance methods of root classes are available as class + methods to other classes as well */ + +@interface RootClass +{ + Class isa; +} +- (id) self; +@end + +@implementation RootClass +- (id) self +{ + return self; +} ++ initialize { return self; } +@end + +@interface NormalClass : RootClass +@end + +@implementation NormalClass : RootClass +@end + +int main (void) +{ + Class normal = objc_getClass ("NormalClass"); + + if (normal == Nil) + { + abort (); + } + + if ([NormalClass self] != normal) + { + abort (); + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/selector-1.m b/gcc-4.9/gcc/testsuite/objc/execute/selector-1.m new file mode 100644 index 000000000..66eee67c0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/selector-1.m @@ -0,0 +1,17 @@ +/* Contributed by Nicola Pero - Thu Mar 8 16:27:46 CET 2001 */ +#include +#include "../../objc-obj-c++-shared/runtime.h" +#include "../../objc-obj-c++-shared/TestsuiteObject.m" + +int main (void) +{ + SEL selector; + char *selname; + + selector = @selector (alloc); + selname = sel_getName (selector); + if (strcmp (selname, "alloc")) + abort (); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/objc/execute/static-1.m b/gcc-4.9/gcc/testsuite/objc/execute/static-1.m new file mode 100644 index 000000000..460f64cc1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/static-1.m @@ -0,0 +1,35 @@ +/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */ +#include + +/* Test defining a static variable *inside* a class implementation */ + +@interface Test +{ + Class isa; +} ++ (int) test; +@end + +@implementation Test + +static int test = 1; + ++ (int) test +{ + return test; +} + ++ initialize { return self; } +@end + +int main (void) +{ + if ([Test test] != 1) + { + abort (); + } + + return 0; +} + + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/static-2.m b/gcc-4.9/gcc/testsuite/objc/execute/static-2.m new file mode 100644 index 000000000..6cdbf5b77 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/static-2.m @@ -0,0 +1,38 @@ +/* Contributed by Nicola Pero - Fri Mar 9 19:39:15 CET 2001 */ +#include + +/* Test defining a static function *inside* a class implementation */ + +@interface Test +{ + Class isa; +} ++ (int) test; +@end + +@implementation Test + +static int test (void) +{ + return 1; +} + ++ (int) test +{ + return test (); +} + ++ initialize { return self; } +@end + +int main (void) +{ + if ([Test test] != 1) + { + abort (); + } + + return 0; +} + + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/trivial.m b/gcc-4.9/gcc/testsuite/objc/execute/trivial.m new file mode 100644 index 000000000..b660a8ffb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/trivial.m @@ -0,0 +1,8 @@ +#import "../../objc-obj-c++-shared/TestsuiteObject.m" + +int main(void) +{ + [TestsuiteObject class]; + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/objc/execute/va_method.m b/gcc-4.9/gcc/testsuite/objc/execute/va_method.m new file mode 100644 index 000000000..190548bac --- /dev/null +++ b/gcc-4.9/gcc/testsuite/objc/execute/va_method.m @@ -0,0 +1,45 @@ +/* Contributed by Nicola Pero - Thu Mar 8 16:27:46 CET 2001 */ +#include +#include + +/* Test method with variable number of arguments */ + +@interface MathClass +{ + Class isa; +} +/* sum positive numbers; -1 ends the list */ ++ (int) sum: (int)firstNumber, ...; +@end + +@implementation MathClass ++ (int) sum: (int)firstNumber, ... +{ + va_list ap; + int sum = 0, number = 0; + + va_start (ap, firstNumber); + number = firstNumber; + + while (number >= 0) + { + sum += number; + number = va_arg (ap, int); + } + + va_end (ap); + + return sum; +} ++ initialize { return self; } +@end + +int main (void) +{ + if ([MathClass sum: 1, 2, 3, 4, 5, -1] != 15) + { + abort (); + } + + return 0; +} -- cgit v1.2.3