aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/obj-c++.dg/qual-types-1.mm
diff options
context:
space:
mode:
author(no author) <(no author)@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-09 23:20:13 +0000
committer(no author) <(no author)@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-09 23:20:13 +0000
commit56dc9c7e121493f4a4225bbfa4be4d65b1753c66 (patch)
tree3dd34a8c34793776e40587f22f12789ab230d69d /gcc/testsuite/obj-c++.dg/qual-types-1.mm
parent9e0f9ffc44b45e738ae0321183bdc41f7c889c81 (diff)
This commit was manufactured by cvs2svn to create tagapple/gcc-5000
'apple-gcc-5000'. git-svn-id: https://gcc.gnu.org/svn/gcc/tags/apple-gcc-5000@96220 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/obj-c++.dg/qual-types-1.mm')
-rw-r--r--gcc/testsuite/obj-c++.dg/qual-types-1.mm72
1 files changed, 72 insertions, 0 deletions
diff --git a/gcc/testsuite/obj-c++.dg/qual-types-1.mm b/gcc/testsuite/obj-c++.dg/qual-types-1.mm
new file mode 100644
index 00000000000..37da232ccbb
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/qual-types-1.mm
@@ -0,0 +1,72 @@
+/* APPLE LOCAL file Objective-C++ */
+/* Test if ObjC++ can distinguish protocol qualifiers from
+ template arguments. */
+/* Author: Ziemowit Laski <zlaski@apple.com>. */
+/* { dg-do run } */
+
+#include <objc/Object.h>
+#include <stdlib.h>
+
+#define CHECK_IF(expr) if(!(expr)) abort()
+
+@protocol Zone
++ allocFromZone:(void *)zone;
+- copyFromZone:(void *)zone;
+@end
+
+@protocol Init <Zone>
++ initialize;
+- init;
+@end
+
+@interface Foo: Object
+{ @public int val; }
+- init;
+@end
+
+template <class T, class U> struct X {
+ T x; U y;
+};
+
+X<int, float> xx;
+
+template <typename T> struct Holder
+{
+ T *obj;
+ static int counter;
+ Holder(void) { obj = [[T alloc] init]; }
+ ~Holder(void) { [obj free]; --counter; }
+ id <Init, Zone> getObjId(void) { return obj; }
+ Object <Zone, Init> *getObj(void) { return obj; }
+};
+
+typedef Holder <Foo <Init, Zone> > FooHolder;
+
+@implementation Foo
+-(id) init {
+ [super init];
+ val = ++FooHolder::counter;
+ return self;
+}
+@end
+
+template <typename T>
+int Holder<T>::counter = 0;
+
+int main (void) {
+ CHECK_IF(FooHolder::counter == 0);
+ {
+ FooHolder holder;
+ CHECK_IF(holder.obj->val == 1);
+ CHECK_IF(FooHolder::counter == 1);
+ FooHolder holder2;
+ CHECK_IF(holder2.obj->val == 2);
+ CHECK_IF(FooHolder::counter == 2);
+ }
+ CHECK_IF(FooHolder::counter == 0);
+ return 0;
+}
+
+
+
+