aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/attributes/method-unavailable-1.m
blob: 7a3de6b245dc013c68472ea1476ace4e64b062a4 (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
/* Test __attribute__ ((unavailable)) */
/* { dg-do compile } */
/* { dg-options "" } */

#include <objc/objc.h>

@interface MyClass
{
  Class isa;
}
+ (int) method;
- (int) method;
+ (int) unavailableClassMethod __attribute__((unavailable));
- (int) unavailableInstanceMethod __attribute__((unavailable));
@end

/* Test that unavailability errors are produced, but not if the
   receiver is of type 'id'.  */
void foo (void)
{
  Class c;
  id object;
  MyClass *another_object;

  [c method];
  [object method];
  [c unavailableClassMethod];
  [object unavailableInstanceMethod];

  [object method];
  [another_object method];
  [MyClass unavailableClassMethod];           /* { dg-error "is unavailable" } */
  [another_object unavailableInstanceMethod]; /* { dg-error "is unavailable" } */
}