Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 1 | // RUN: %clang -cc1 -emit-pch -x objective-c++ -std=c++0x -o %t %s |
| 2 | // RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -verify %s |
| 3 | // RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=PRINT %s |
| 4 | // RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -emit-llvm -o - %s | FileCheck -check-prefix=IR %s |
| 5 | |
Andy Gibbs | 8e8fb3b | 2012-10-19 12:44:48 +0000 | [diff] [blame^] | 6 | // expected-no-diagnostics |
| 7 | |
Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame] | 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 | template<typename T, typename U> |
| 43 | struct pair { |
| 44 | T first; |
| 45 | U second; |
| 46 | }; |
| 47 | |
| 48 | template<typename T, typename U> |
| 49 | pair<T, U> make_pair(const T& first, const U& second) { |
| 50 | return { first, second }; |
| 51 | } |
| 52 | |
| 53 | // CHECK-IR: define linkonce_odr void @_Z29variadic_dictionary_expansionIJP8NSStringS1_EJP8NSNumberS3_EEvDp4pairIT_T0_E |
| 54 | template<typename ...Ts, typename ... Us> |
| 55 | void variadic_dictionary_expansion(pair<Ts, Us>... key_values) { |
| 56 | // CHECK-PRINT: id dict = @{ key_values.first : key_values.second... }; |
| 57 | // CHECK-IR: {{call.*objc_msgSend}} |
| 58 | // CHECK-IR: ret void |
| 59 | id dict = @{ key_values.first : key_values.second ... }; |
| 60 | } |
| 61 | |
| 62 | #else |
| 63 | void test_all() { |
| 64 | variadic_dictionary_expansion(make_pair(@"Seventeen", @17), |
| 65 | make_pair(@"YES", @true)); |
| 66 | } |
| 67 | #endif |