summaryrefslogtreecommitdiff
path: root/gcc/testsuite/obj-c++.dg/method-22.mm
blob: 610c178e92a0631bf14cebabc1ebf7cc88939358 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* Ensure that overload resolution does not produce warnings as
   side-effects.  */
/* { dg-do run } */
/* { dg-additional-sources "../objc-obj-c++-shared/Object1.mm" } */
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */

#include "../objc-obj-c++-shared/Object1.h"
#include <stdlib.h>

#define CHECK_IF(E) if(!(E)) abort ()

@interface MyCursor: Object
+ (MyCursor *)crosshairCursor;
@end

@class MyImage;

class A {
public:
    A();
    
    int foo(MyImage *);
    int foo(MyCursor *);
};

A::A() {}
int A::foo(MyCursor * c) { return 17; }
int A::foo(MyImage * i) { return 29; }

@implementation MyCursor
+ (MyCursor *)crosshairCursor {
  return self;
}
@end

int main(void) {
  A a;
  
  int r = a.foo([MyCursor crosshairCursor]);

  CHECK_IF (r == 17);    
  return 0;
}