summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/zero-link-1.m
blob: 812267bc376df32fe8b5fb24206494177f3d3ae0 (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
/* Check if the '-fzero-link' flag correctly emits an objc_getClass() call. */
/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */

/* { dg-do compile { target *-*-darwin*  } } */
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
/* { dg-options "-fzero-link" } */

#include <Foundation/NSObject.h>

extern void abort(void);
#define CHECK_IF(expr) if(!(expr)) abort();

@interface Base: NSObject
+ (int) getValue;
@end

@implementation Base
+ (int) getValue { return 1593; }
@end

int main(void) {
  int val = [Base getValue];
  CHECK_IF(val == 1593);
  return 0;
}

/* { dg-final { scan-assembler-not "_OBJC_ClassRefs_0" { target { *-*-darwin* && { ! lp64 } } } } } */
/* { dg-final { scan-assembler-not "_OBJC_ClassRef_Base" { target { *-*-darwin* && { lp64 } } } } } */
/* { dg-final { scan-assembler "objc_getClass" } } */