1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 3 // Obj-C string literal expressions 4 template <typename T> struct StringTest { 5 void f() { 6 (void)@"Hello"; 7 } 8 }; 9 10 template struct StringTest<int>; 11 template struct StringTest<double>; 12 13 // @selector expressions 14 template <typename T> struct SelectorTest { 15 SEL f() { 16 return @selector(multiple:arguments:); 17 } 18 SEL f2() { 19 return @selector(multiple:arguments:); 20 } 21 }; 22 23 template struct SelectorTest<int>; 24 template struct SelectorTest<double>; 25 26 // @protocol expressions 27 @protocol P 28 @end 29 30 template <typename T> struct ProtocolTest { 31 void f() { 32 (void)@protocol(P); 33 } 34 }; 35 36 template struct ProtocolTest<int>; 37 template struct ProtocolTest<double>; 38 39 // @encode expressions 40 template <typename T> struct EncodeTest { 41 static const char *encode(T t) { 42 return @encode(T); 43 } 44 }; 45 46 template struct EncodeTest<int>; 47 template struct EncodeTest<double>; 48 template struct EncodeTest<wchar_t>; 49 50 // @() boxing expressions. 51 template <typename T> struct BoxingTest { 52 static id box(T value) { 53 return @(value); // expected-error {{illegal type 'int *' used in a boxed expression}} \ 54 // expected-error {{illegal type 'long double' used in a boxed expression}} 55 } 56 }; 57 58 @interface NSNumber 59 + (NSNumber *)numberWithInt:(int)value; 60 @end 61 62 @interface NSString 63 + (id)stringWithUTF8String:(const char *)str; 64 @end 65 66 template struct BoxingTest<int>; 67 template struct BoxingTest<const char *>; 68 template struct BoxingTest<int *>; // expected-note {{in instantiation of member function 'BoxingTest<int *>::box' requested here}} 69 template struct BoxingTest<long double>; // expected-note {{in instantiation of member function 'BoxingTest<long double>::box' requested here}} 70