1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s 3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 4 5 template <typename T> struct S { 6 S() { } 7 S(T t); 8 }; 9 10 template struct S<int>; 11 12 void f() { 13 S<int> s1; 14 S<int> s2(10); 15 } 16 17 namespace PR7184 { 18 template<typename T> 19 void f() { 20 typedef T type; 21 void g(int array[sizeof(type)]); 22 } 23 24 template void f<int>(); 25 } 26 27 namespace UsedAttr { 28 template<typename T> 29 void __attribute__((used)) foo() { 30 T *x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} 31 } 32 33 void bar() { 34 foo<int>(); // expected-note{{instantiation of}} 35 } 36 } 37 38 namespace PR9654 { 39 typedef void ftype(int); 40 41 template<typename T> 42 ftype f; 43 44 void g() { 45 f<int>(0); 46 } 47 } 48 49 namespace AliasTagDef { 50 template<typename T> 51 T f() { 52 using S = struct { 53 #if __cplusplus <= 199711L 54 // expected-warning@-2 {{alias declarations are a C++11 extension}} 55 #endif 56 T g() { 57 return T(); 58 } 59 }; 60 return S().g(); 61 } 62 63 int n = f<int>(); 64 } 65 66 namespace PR10273 { 67 template<typename T> void (f)(T t) {} 68 69 void g() { 70 (f)(17); 71 } 72 } 73 74 namespace rdar15464547 { 75 class A { 76 A(); 77 }; 78 79 template <typename R> class B { 80 public: 81 static void meth1(); 82 static void meth2(); 83 }; 84 85 A::A() { 86 extern int compile_time_assert_failed; 87 B<int>::meth2(); 88 } 89 90 template <typename R> void B<R>::meth1() { 91 extern int compile_time_assert_failed; 92 } 93 94 template <typename R> void B<R>::meth2() { 95 extern int compile_time_assert_failed; 96 } 97 } 98