cgraph: A COMDAT decl always has non-zero address.
[gcc.git] / gcc / testsuite / obj-c++.dg / cxx-scope-1.mm
1 /* Handle C++ scoping ('::') operators in ObjC message receivers gracefully. */
2 /* Author: Ziemowit Laski <zlaski@apple.com> */
3
4 /* { dg-do run } */
5 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6 #include "../objc-obj-c++-shared/TestsuiteObject.m"
7 #include <stdlib.h>
8
9 @class Derived;
10
11 Derived *inst[3];
12
13 struct CxxClass {
14 static Derived *get_instance(int);
15 };
16
17 Derived *CxxClass::get_instance(int offs) {
18 return inst[offs];
19 }
20
21 @interface Derived: TestsuiteObject {
22 int value;
23 }
24 -(id)initWithValue:(int)val;
25 -(int)derived_meth;
26 @end
27
28 @implementation Derived
29 -(id)initWithValue:(int)val {
30 [super init];
31 value = val;
32 return self;
33 }
34 - (int)derived_meth {
35 return value;
36 }
37 @end
38
39 int main(void) {
40 int r;
41 inst[1] = [[::Derived alloc] initWithValue:7];
42 inst[2] = [[Derived alloc] initWithValue:77];
43
44 r = [CxxClass::get_instance(2) derived_meth];
45 if (r != 77)
46 abort();
47
48 r = [CxxClass::get_instance(1) derived_meth];
49 if (r != 7)
50 abort();
51
52 return 0;
53 }
54