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