• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: rm -rf %t
2// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++
3// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
4// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result
5
6#define YES __objc_yes
7#define NO __objc_no
8
9typedef long NSInteger;
10typedef unsigned long NSUInteger;
11typedef signed char BOOL;
12#define nil ((void*) 0)
13
14@interface NSObject
15+ (id)alloc;
16@end
17
18@interface NSNumber : NSObject
19@end
20
21@interface NSNumber (NSNumberCreation)
22- (id)initWithChar:(char)value;
23- (id)initWithUnsignedChar:(unsigned char)value;
24- (id)initWithShort:(short)value;
25- (id)initWithUnsignedShort:(unsigned short)value;
26- (id)initWithInt:(int)value;
27- (id)initWithUnsignedInt:(unsigned int)value;
28- (id)initWithLong:(long)value;
29- (id)initWithUnsignedLong:(unsigned long)value;
30- (id)initWithLongLong:(long long)value;
31- (id)initWithUnsignedLongLong:(unsigned long long)value;
32- (id)initWithFloat:(float)value;
33- (id)initWithDouble:(double)value;
34- (id)initWithBool:(BOOL)value;
35- (id)initWithInteger:(NSInteger)value;
36- (id)initWithUnsignedInteger:(NSUInteger)value;
37
38+ (NSNumber *)numberWithChar:(char)value;
39+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
40+ (NSNumber *)numberWithShort:(short)value;
41+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
42+ (NSNumber *)numberWithInt:(int)value;
43+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
44+ (NSNumber *)numberWithLong:(long)value;
45+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
46+ (NSNumber *)numberWithLongLong:(long long)value;
47+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
48+ (NSNumber *)numberWithFloat:(float)value;
49+ (NSNumber *)numberWithDouble:(double)value;
50+ (NSNumber *)numberWithBool:(BOOL)value;
51+ (NSNumber *)numberWithInteger:(NSInteger)value;
52+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
53@end
54
55#define VAL_INT 2
56#define VAL_UINT 2U
57#define VAL_CHAR 'a'
58
59void foo() {
60  @'a';
61  [NSNumber numberWithChar:L'a'];
62  [NSNumber numberWithChar:2];
63  [NSNumber numberWithChar:2U];
64  [NSNumber numberWithChar:2u];
65  [NSNumber numberWithChar:2L];
66  [NSNumber numberWithChar:2l];
67  [NSNumber numberWithChar:2LL];
68  [NSNumber numberWithChar:2ll];
69  [NSNumber numberWithChar:2ul];
70  [NSNumber numberWithChar:2lu];
71  [NSNumber numberWithChar:2ull];
72  [NSNumber numberWithChar:2llu];
73  [NSNumber numberWithChar:2.0];
74  [NSNumber numberWithChar:2.0f];
75  [NSNumber numberWithChar:2.0F];
76  [NSNumber numberWithChar:2.0l];
77  [NSNumber numberWithChar:2.0L];
78  [NSNumber numberWithChar:0x2f];
79  [NSNumber numberWithChar:04];
80  [NSNumber numberWithChar:0];
81  [NSNumber numberWithChar:0.0];
82  [NSNumber numberWithChar:YES];
83  [NSNumber numberWithChar:NO];
84  [NSNumber numberWithChar:true];
85  [NSNumber numberWithChar:false];
86  [NSNumber numberWithChar:VAL_INT];
87  [NSNumber numberWithChar:VAL_UINT];
88  @VAL_CHAR;
89
90  [NSNumber numberWithUnsignedChar:'a'];
91  [NSNumber numberWithUnsignedChar:L'a'];
92  [NSNumber numberWithUnsignedChar:2];
93  [NSNumber numberWithUnsignedChar:2U];
94  [NSNumber numberWithUnsignedChar:2u];
95  [NSNumber numberWithUnsignedChar:2L];
96  [NSNumber numberWithUnsignedChar:2l];
97  [NSNumber numberWithUnsignedChar:2LL];
98  [NSNumber numberWithUnsignedChar:2ll];
99  [NSNumber numberWithUnsignedChar:2ul];
100  [NSNumber numberWithUnsignedChar:2lu];
101  [NSNumber numberWithUnsignedChar:2ull];
102  [NSNumber numberWithUnsignedChar:2llu];
103  [NSNumber numberWithUnsignedChar:2.0];
104  [NSNumber numberWithUnsignedChar:2.0f];
105  [NSNumber numberWithUnsignedChar:2.0F];
106  [NSNumber numberWithUnsignedChar:2.0l];
107  [NSNumber numberWithUnsignedChar:2.0L];
108  [NSNumber numberWithUnsignedChar:0x2f];
109  [NSNumber numberWithUnsignedChar:04];
110  [NSNumber numberWithUnsignedChar:0];
111  [NSNumber numberWithUnsignedChar:0.0];
112  [NSNumber numberWithUnsignedChar:YES];
113  [NSNumber numberWithUnsignedChar:NO];
114  [NSNumber numberWithUnsignedChar:true];
115  [NSNumber numberWithUnsignedChar:false];
116  [NSNumber numberWithUnsignedChar:VAL_INT];
117  [NSNumber numberWithUnsignedChar:VAL_UINT];
118  [NSNumber numberWithUnsignedChar:VAL_CHAR];
119
120  [NSNumber numberWithShort:'a'];
121  [NSNumber numberWithShort:L'a'];
122  [NSNumber numberWithShort:2];
123  [NSNumber numberWithShort:2U];
124  [NSNumber numberWithShort:2u];
125  [NSNumber numberWithShort:2L];
126  [NSNumber numberWithShort:2l];
127  [NSNumber numberWithShort:2LL];
128  [NSNumber numberWithShort:2ll];
129  [NSNumber numberWithShort:2ul];
130  [NSNumber numberWithShort:2lu];
131  [NSNumber numberWithShort:2ull];
132  [NSNumber numberWithShort:2llu];
133  [NSNumber numberWithShort:2.0];
134  [NSNumber numberWithShort:2.0f];
135  [NSNumber numberWithShort:2.0F];
136  [NSNumber numberWithShort:2.0l];
137  [NSNumber numberWithShort:2.0L];
138  [NSNumber numberWithShort:0x2f];
139  [NSNumber numberWithShort:04];
140  [NSNumber numberWithShort:0];
141  [NSNumber numberWithShort:0.0];
142  [NSNumber numberWithShort:YES];
143  [NSNumber numberWithShort:NO];
144  [NSNumber numberWithShort:true];
145  [NSNumber numberWithShort:false];
146  [NSNumber numberWithShort:VAL_INT];
147  [NSNumber numberWithShort:VAL_UINT];
148
149  [NSNumber numberWithUnsignedShort:'a'];
150  [NSNumber numberWithUnsignedShort:L'a'];
151  [NSNumber numberWithUnsignedShort:2];
152  [NSNumber numberWithUnsignedShort:2U];
153  [NSNumber numberWithUnsignedShort:2u];
154  [NSNumber numberWithUnsignedShort:2L];
155  [NSNumber numberWithUnsignedShort:2l];
156  [NSNumber numberWithUnsignedShort:2LL];
157  [NSNumber numberWithUnsignedShort:2ll];
158  [NSNumber numberWithUnsignedShort:2ul];
159  [NSNumber numberWithUnsignedShort:2lu];
160  [NSNumber numberWithUnsignedShort:2ull];
161  [NSNumber numberWithUnsignedShort:2llu];
162  [NSNumber numberWithUnsignedShort:2.0];
163  [NSNumber numberWithUnsignedShort:2.0f];
164  [NSNumber numberWithUnsignedShort:2.0F];
165  [NSNumber numberWithUnsignedShort:2.0l];
166  [NSNumber numberWithUnsignedShort:2.0L];
167  [NSNumber numberWithUnsignedShort:0x2f];
168  [NSNumber numberWithUnsignedShort:04];
169  [NSNumber numberWithUnsignedShort:0];
170  [NSNumber numberWithUnsignedShort:0.0];
171  [NSNumber numberWithUnsignedShort:YES];
172  [NSNumber numberWithUnsignedShort:NO];
173  [NSNumber numberWithUnsignedShort:true];
174  [NSNumber numberWithUnsignedShort:false];
175  [NSNumber numberWithUnsignedShort:VAL_INT];
176  [NSNumber numberWithUnsignedShort:VAL_UINT];
177
178  [NSNumber numberWithInt:'a'];
179  [NSNumber numberWithInt:L'a'];
180  @2;
181  @2;
182  @2;
183  @2;
184  @2;
185  @2;
186  @2;
187  @2;
188  @2;
189  @2;
190  @2;
191  [NSNumber numberWithInt:2.0];
192  [NSNumber numberWithInt:2.0f];
193  [NSNumber numberWithInt:2.0F];
194  [NSNumber numberWithInt:2.0l];
195  [NSNumber numberWithInt:2.0L];
196  @0x2f;
197  @04;
198  @0;
199  [NSNumber numberWithInt:0.0];
200  [NSNumber numberWithInt:YES];
201  [NSNumber numberWithInt:NO];
202  [NSNumber numberWithInt:true];
203  [NSNumber numberWithInt:false];
204  @VAL_INT;
205  [NSNumber numberWithInt:VAL_UINT];
206
207  (void)[[NSNumber alloc] initWithInt:2];
208  (void)[[NSNumber alloc] initWithInt:2U];
209
210  @+2;
211  @-2;
212
213  [NSNumber numberWithUnsignedInt:'a'];
214  [NSNumber numberWithUnsignedInt:L'a'];
215  @2U;
216  @2U;
217  @2u;
218  @2U;
219  @2u;
220  @2U;
221  @2u;
222  @2u;
223  @2u;
224  @2u;
225  @2u;
226  [NSNumber numberWithUnsignedInt:2.0];
227  [NSNumber numberWithUnsignedInt:2.0f];
228  [NSNumber numberWithUnsignedInt:2.0F];
229  [NSNumber numberWithUnsignedInt:2.0l];
230  [NSNumber numberWithUnsignedInt:2.0L];
231  @0x2fU;
232  @04U;
233  @0U;
234  [NSNumber numberWithUnsignedInt:0.0];
235  [NSNumber numberWithUnsignedInt:YES];
236  [NSNumber numberWithUnsignedInt:NO];
237  [NSNumber numberWithUnsignedInt:true];
238  [NSNumber numberWithUnsignedInt:false];
239  [NSNumber numberWithUnsignedInt:VAL_INT];
240  @VAL_UINT;
241
242  [NSNumber numberWithLong:'a'];
243  [NSNumber numberWithLong:L'a'];
244  @2L;
245  @2L;
246  @2l;
247  @2L;
248  @2l;
249  @2L;
250  @2l;
251  @2l;
252  @2l;
253  @2l;
254  @2l;
255  [NSNumber numberWithLong:2.0];
256  [NSNumber numberWithLong:2.0f];
257  [NSNumber numberWithLong:2.0F];
258  [NSNumber numberWithLong:2.0l];
259  [NSNumber numberWithLong:2.0L];
260  @0x2fL;
261  @04L;
262  @0L;
263  [NSNumber numberWithLong:0.0];
264  [NSNumber numberWithLong:YES];
265  [NSNumber numberWithLong:NO];
266  [NSNumber numberWithLong:true];
267  [NSNumber numberWithLong:false];
268  [NSNumber numberWithLong:VAL_INT];
269  [NSNumber numberWithLong:VAL_UINT];
270
271  [NSNumber numberWithUnsignedLong:'a'];
272  [NSNumber numberWithUnsignedLong:L'a'];
273  @2UL;
274  @2UL;
275  @2ul;
276  @2UL;
277  @2ul;
278  @2UL;
279  @2ul;
280  @2ul;
281  @2lu;
282  @2ul;
283  @2ul;
284  [NSNumber numberWithUnsignedLong:2.0];
285  [NSNumber numberWithUnsignedLong:2.0f];
286  [NSNumber numberWithUnsignedLong:2.0F];
287  [NSNumber numberWithUnsignedLong:2.0l];
288  [NSNumber numberWithUnsignedLong:2.0L];
289  @0x2fUL;
290  @04UL;
291  @0UL;
292  [NSNumber numberWithUnsignedLong:0.0];
293  [NSNumber numberWithUnsignedLong:YES];
294  [NSNumber numberWithUnsignedLong:NO];
295  [NSNumber numberWithUnsignedLong:true];
296  [NSNumber numberWithUnsignedLong:false];
297  [NSNumber numberWithUnsignedLong:VAL_INT];
298  [NSNumber numberWithUnsignedLong:VAL_UINT];
299
300  [NSNumber numberWithLongLong:'a'];
301  [NSNumber numberWithLongLong:L'a'];
302  @2LL;
303  @2LL;
304  @2ll;
305  @2LL;
306  @2ll;
307  @2LL;
308  @2ll;
309  @2ll;
310  @2ll;
311  @2ll;
312  @2ll;
313  [NSNumber numberWithLongLong:2.0];
314  [NSNumber numberWithLongLong:2.0f];
315  [NSNumber numberWithLongLong:2.0F];
316  [NSNumber numberWithLongLong:2.0l];
317  [NSNumber numberWithLongLong:2.0L];
318  @0x2fLL;
319  @04LL;
320  @0LL;
321  [NSNumber numberWithLongLong:0.0];
322  [NSNumber numberWithLongLong:YES];
323  [NSNumber numberWithLongLong:NO];
324  [NSNumber numberWithLongLong:true];
325  [NSNumber numberWithLongLong:false];
326  [NSNumber numberWithLongLong:VAL_INT];
327  [NSNumber numberWithLongLong:VAL_UINT];
328
329  [NSNumber numberWithUnsignedLongLong:'a'];
330  [NSNumber numberWithUnsignedLongLong:L'a'];
331  @2ULL;
332  @2ULL;
333  @2ull;
334  @2ULL;
335  @2ull;
336  @2ULL;
337  @2ull;
338  @2ull;
339  @2ull;
340  @2ull;
341  @2llu;
342  [NSNumber numberWithUnsignedLongLong:2.0];
343  [NSNumber numberWithUnsignedLongLong:2.0f];
344  [NSNumber numberWithUnsignedLongLong:2.0F];
345  [NSNumber numberWithUnsignedLongLong:2.0l];
346  [NSNumber numberWithUnsignedLongLong:2.0L];
347  @0x2fULL;
348  @04ULL;
349  @0ULL;
350  [NSNumber numberWithUnsignedLongLong:0.0];
351  [NSNumber numberWithUnsignedLongLong:YES];
352  [NSNumber numberWithUnsignedLongLong:NO];
353  [NSNumber numberWithUnsignedLongLong:true];
354  [NSNumber numberWithUnsignedLongLong:false];
355  [NSNumber numberWithUnsignedLongLong:VAL_INT];
356  [NSNumber numberWithUnsignedLongLong:VAL_UINT];
357
358  [NSNumber numberWithFloat:'a'];
359  [NSNumber numberWithFloat:L'a'];
360  @2.0f;
361  @2.0f;
362  @2.0f;
363  @2.0f;
364  @2.0f;
365  @2.0f;
366  @2.0f;
367  @2.0f;
368  @2.0f;
369  @2.0f;
370  @2.0f;
371  @2.0f;
372  @2.0f;
373  @2.0F;
374  @2.0f;
375  @2.0f;
376  [NSNumber numberWithFloat:0x2f];
377  [NSNumber numberWithFloat:04];
378  @0.0f;
379  @0.0f;
380  [NSNumber numberWithFloat:YES];
381  [NSNumber numberWithFloat:NO];
382  [NSNumber numberWithFloat:true];
383  [NSNumber numberWithFloat:false];
384  [NSNumber numberWithFloat:VAL_INT];
385  [NSNumber numberWithFloat:VAL_UINT];
386
387  [NSNumber numberWithDouble:'a'];
388  [NSNumber numberWithDouble:L'a'];
389  @2.0;
390  @2.0;
391  @2.0;
392  @2.0;
393  @2.0;
394  @2.0;
395  @2.0;
396  @2.0;
397  @2.0;
398  @2.0;
399  @2.0;
400  @2.0;
401  @2.0;
402  @2.0;
403  @2.0;
404  @2.0;
405  [NSNumber numberWithDouble:0x2f];
406  [NSNumber numberWithDouble:04];
407  @0.0;
408  @0.0;
409  [NSNumber numberWithDouble:YES];
410  [NSNumber numberWithDouble:NO];
411  [NSNumber numberWithDouble:true];
412  [NSNumber numberWithDouble:false];
413  [NSNumber numberWithDouble:VAL_INT];
414  [NSNumber numberWithDouble:VAL_UINT];
415
416  [NSNumber numberWithBool:'a'];
417  [NSNumber numberWithBool:L'a'];
418  [NSNumber numberWithBool:2];
419  [NSNumber numberWithBool:2U];
420  [NSNumber numberWithBool:2u];
421  [NSNumber numberWithBool:2L];
422  [NSNumber numberWithBool:2l];
423  [NSNumber numberWithBool:2LL];
424  [NSNumber numberWithBool:2ll];
425  [NSNumber numberWithBool:2ul];
426  [NSNumber numberWithBool:2lu];
427  [NSNumber numberWithBool:2ull];
428  [NSNumber numberWithBool:2llu];
429  [NSNumber numberWithBool:2.0];
430  [NSNumber numberWithBool:2.0f];
431  [NSNumber numberWithBool:2.0F];
432  [NSNumber numberWithBool:2.0l];
433  [NSNumber numberWithBool:2.0L];
434  [NSNumber numberWithBool:0x2f];
435  [NSNumber numberWithBool:04];
436  [NSNumber numberWithBool:0];
437  [NSNumber numberWithBool:0.0];
438  @YES;
439  @NO;
440  @true;
441  @false;
442  [NSNumber numberWithBool:VAL_INT];
443  [NSNumber numberWithBool:VAL_UINT];
444
445  [NSNumber numberWithInteger:'a'];
446  [NSNumber numberWithInteger:L'a'];
447  @2;
448  @2;
449  @2;
450  @2L;
451  @2l;
452  @2;
453  @2;
454  @2;
455  @2;
456  @2;
457  @2;
458  [NSNumber numberWithInteger:2.0];
459  [NSNumber numberWithInteger:2.0f];
460  [NSNumber numberWithInteger:2.0F];
461  [NSNumber numberWithInteger:2.0l];
462  [NSNumber numberWithInteger:2.0L];
463  @0x2f;
464  @04;
465  @0;
466  [NSNumber numberWithInteger:0.0];
467  [NSNumber numberWithInteger:YES];
468  [NSNumber numberWithInteger:NO];
469  [NSNumber numberWithInteger:true];
470  [NSNumber numberWithInteger:false];
471  @VAL_INT;
472  [NSNumber numberWithInteger:VAL_UINT];
473
474  [NSNumber numberWithUnsignedInteger:'a'];
475  [NSNumber numberWithUnsignedInteger:L'a'];
476  @2U;
477  @2U;
478  @2u;
479  @2U;
480  @2u;
481  @2U;
482  @2u;
483  @2ul;
484  @2lu;
485  @2u;
486  @2u;
487  [NSNumber numberWithUnsignedInteger:2.0];
488  [NSNumber numberWithUnsignedInteger:2.0f];
489  [NSNumber numberWithUnsignedInteger:2.0F];
490  [NSNumber numberWithUnsignedInteger:2.0l];
491  [NSNumber numberWithUnsignedInteger:2.0L];
492  @0x2fU;
493  @04U;
494  @0U;
495  [NSNumber numberWithUnsignedInteger:0.0];
496  [NSNumber numberWithUnsignedInteger:YES];
497  [NSNumber numberWithUnsignedInteger:NO];
498  [NSNumber numberWithUnsignedInteger:true];
499  [NSNumber numberWithUnsignedInteger:false];
500  [NSNumber numberWithUnsignedInteger:VAL_INT];
501  @VAL_UINT;
502}
503