Home | History | Annotate | Download | only in PCH
      1 // RUN: %clang_cc1 -emit-pch -o %t %s
      2 // RUN: %clang_cc1 -include-pch %t -verify %s
      3 // RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=PRINT %s
      4 // RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=IR %s
      5 
      6 // expected-no-diagnostics
      7 
      8 #ifndef HEADER
      9 #define HEADER
     10 
     11 typedef unsigned char BOOL;
     12 
     13 @interface NSNumber @end
     14 
     15 @interface NSNumber (NSNumberCreation)
     16 + (NSNumber *)numberWithChar:(char)value;
     17 + (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
     18 + (NSNumber *)numberWithShort:(short)value;
     19 + (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
     20 + (NSNumber *)numberWithInt:(int)value;
     21 + (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
     22 + (NSNumber *)numberWithLong:(long)value;
     23 + (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
     24 + (NSNumber *)numberWithLongLong:(long long)value;
     25 + (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
     26 + (NSNumber *)numberWithFloat:(float)value;
     27 + (NSNumber *)numberWithDouble:(double)value;
     28 + (NSNumber *)numberWithBool:(BOOL)value;
     29 @end
     30 
     31 @interface NSArray
     32 @end
     33 
     34 @interface NSArray (NSArrayCreation)
     35 + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
     36 @end
     37 
     38 @interface NSDictionary
     39 + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
     40 @end
     41 
     42 // CHECK-IR: define internal void @test_numeric_literals()
     43 static inline void test_numeric_literals() {
     44   // CHECK-PRINT: id intlit = @17
     45   // CHECK-IR: {{call.*17}}
     46   id intlit = @17;
     47   // CHECK-PRINT: id floatlit = @17.45
     48   // CHECK-IR: {{call.*1.745}}
     49   id floatlit = @17.45;
     50 }
     51 
     52 static inline void test_array_literals() {
     53   // CHECK-PRINT: id arraylit = @[ @17, @17.45
     54   id arraylit = @[@17, @17.45];
     55 }
     56 
     57 static inline void test_dictionary_literals() {
     58   // CHECK-PRINT: id dictlit = @{ @17 : {{@17.45[^,]*}}, @"hello" : @"world" };
     59   id dictlit = @{@17 : @17.45, @"hello" : @"world" };
     60 }
     61 
     62 #else
     63 void test_all() {
     64   test_numeric_literals();
     65   test_array_literals();
     66   test_dictionary_literals();
     67 }
     68 #endif
     69