• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes %s
2
3typedef long NSInteger;
4typedef unsigned long NSUInteger;
5typedef signed char BOOL;
6
7@interface NSNumber
8@end
9@interface NSNumber (NSNumberCreation)
10+ (NSNumber *)numberWithChar:(char)value;
11+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
12+ (NSNumber *)numberWithShort:(short)value;
13+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
14+ (NSNumber *)numberWithInt:(int)value;
15+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
16+ (NSNumber *)numberWithLong:(long)value;
17+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
18+ (NSNumber *)numberWithLongLong:(long long)value;
19+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
20+ (NSNumber *)numberWithFloat:(float)value;
21+ (NSNumber *)numberWithDouble:(double)value;
22+ (NSNumber *)numberWithBool:(BOOL)value;
23+ (NSNumber *)numberWithInteger:(NSInteger)value;
24+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
25@end
26
27typedef struct {
28    int x, y, z;
29} point;
30
31void testStruct() {
32    point p = { 0, 0, 0 };
33    id boxed = @(p);    // expected-error {{illegal type 'point' used in a boxed expression}}
34}
35
36void testPointers() {
37    void *null = 0;
38    id boxed_null = @(null);        // expected-error {{illegal type 'void *' used in a boxed expression}}
39    int numbers[] = { 0, 1, 2 };
40    id boxed_numbers = @(numbers);  // expected-error {{illegal type 'int *' used in a boxed expression}}
41}
42
43void testInvalid() {
44  @(not_defined); // expected-error {{use of undeclared identifier 'not_defined'}}
45}
46
47enum MyEnum {
48  ME_foo
49};
50
51enum ForwE; // expected-error {{ISO C++ forbids forward references to 'enum' types}}
52
53void testEnum(void *p) {
54  enum MyEnum myen;
55  id box = @(myen);
56  box = @(ME_foo);
57  box = @(*(enum ForwE*)p); // expected-error {{incomplete type 'enum ForwE' used in a boxed expression}}
58}
59