xref: /minix3/external/bsd/llvm/dist/clang/test/PCH/objc_literals.mm (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-pch -x objective-c++ -std=c++0x -o %t %s
2*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -verify %s
3*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
4*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-IR %s
5f4a2713aSLionel Sambuc
6f4a2713aSLionel Sambuc// expected-no-diagnostics
7f4a2713aSLionel Sambuc
8f4a2713aSLionel Sambuc#ifndef HEADER
9f4a2713aSLionel Sambuc#define HEADER
10f4a2713aSLionel Sambuc
11f4a2713aSLionel Sambuctypedef unsigned char BOOL;
12f4a2713aSLionel Sambuc
13f4a2713aSLionel Sambuc@interface NSNumber @end
14f4a2713aSLionel Sambuc
15f4a2713aSLionel Sambuc@interface NSNumber (NSNumberCreation)
16f4a2713aSLionel Sambuc+ (NSNumber *)numberWithChar:(char)value;
17f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
18f4a2713aSLionel Sambuc+ (NSNumber *)numberWithShort:(short)value;
19f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
20f4a2713aSLionel Sambuc+ (NSNumber *)numberWithInt:(int)value;
21f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
22f4a2713aSLionel Sambuc+ (NSNumber *)numberWithLong:(long)value;
23f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
24f4a2713aSLionel Sambuc+ (NSNumber *)numberWithLongLong:(long long)value;
25f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
26f4a2713aSLionel Sambuc+ (NSNumber *)numberWithFloat:(float)value;
27f4a2713aSLionel Sambuc+ (NSNumber *)numberWithDouble:(double)value;
28f4a2713aSLionel Sambuc+ (NSNumber *)numberWithBool:(BOOL)value;
29f4a2713aSLionel Sambuc@end
30f4a2713aSLionel Sambuc
31f4a2713aSLionel Sambuc@interface NSArray
32f4a2713aSLionel Sambuc@end
33f4a2713aSLionel Sambuc
34f4a2713aSLionel Sambuc@interface NSArray (NSArrayCreation)
35f4a2713aSLionel Sambuc+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
36f4a2713aSLionel Sambuc@end
37f4a2713aSLionel Sambuc
38f4a2713aSLionel Sambuc@interface NSDictionary
39f4a2713aSLionel Sambuc+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
40f4a2713aSLionel Sambuc@end
41f4a2713aSLionel Sambuc
42f4a2713aSLionel Sambuctemplate<typename T, typename U>
43f4a2713aSLionel Sambucstruct pair {
44f4a2713aSLionel Sambuc  T first;
45f4a2713aSLionel Sambuc  U second;
46f4a2713aSLionel Sambuc};
47f4a2713aSLionel Sambuc
48f4a2713aSLionel Sambuctemplate<typename T, typename U>
49f4a2713aSLionel Sambucpair<T, U> make_pair(const T& first, const U& second) {
50f4a2713aSLionel Sambuc  return { first, second };
51f4a2713aSLionel Sambuc}
52f4a2713aSLionel Sambuc
53f4a2713aSLionel Sambuc// CHECK-IR: define linkonce_odr void @_Z29variadic_dictionary_expansionIJP8NSStringS1_EJP8NSNumberS3_EEvDp4pairIT_T0_E
54f4a2713aSLionel Sambuctemplate<typename ...Ts, typename ... Us>
55f4a2713aSLionel Sambucvoid variadic_dictionary_expansion(pair<Ts, Us>... key_values) {
56f4a2713aSLionel Sambuc  // CHECK-PRINT: id dict = @{ key_values.first : key_values.second... };
57f4a2713aSLionel Sambuc  // CHECK-IR: {{call.*objc_msgSend}}
58f4a2713aSLionel Sambuc  // CHECK-IR: ret void
59f4a2713aSLionel Sambuc  id dict = @{ key_values.first : key_values.second ... };
60f4a2713aSLionel Sambuc}
61f4a2713aSLionel Sambuc
62f4a2713aSLionel Sambuc#else
63f4a2713aSLionel Sambucvoid test_all() {
64f4a2713aSLionel Sambuc  variadic_dictionary_expansion(make_pair(@"Seventeen", @17),
65f4a2713aSLionel Sambuc                                make_pair(@"YES", @true));
66f4a2713aSLionel Sambuc}
67f4a2713aSLionel Sambuc#endif
68