1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 // expected-no-diagnostics 3 4 // PR5908 5 template <typename Iterator> Test(Iterator it)6void Test(Iterator it) { 7 *(it += 1); 8 } 9 10 namespace PR6045 { 11 template<unsigned int r> 12 class A 13 { 14 static const unsigned int member = r; 15 void f(); 16 }; 17 18 template<unsigned int r> 19 const unsigned int A<r>::member; 20 21 template<unsigned int r> f()22 void A<r>::f() 23 { 24 unsigned k; 25 (void)(k % member); 26 } 27 } 28 29 namespace PR7198 { 30 struct A 31 { ~APR7198::A32 ~A() { } 33 }; 34 35 template<typename T> 36 struct B { 37 struct C : A {}; fPR7198::B38 void f() 39 { 40 C c = C(); 41 } 42 }; 43 } 44 45 namespace PR7724 { myMethod()46 template<typename OT> int myMethod() 47 { return 2 && sizeof(OT); } 48 } 49 50 namespace test4 { addressof(T & v)51 template <typename T> T *addressof(T &v) { 52 return reinterpret_cast<T*>( 53 &const_cast<char&>(reinterpret_cast<const volatile char &>(v))); 54 } 55 } 56 57 namespace test5 { 58 template <typename T> class chained_map { 59 int k; lookup() const60 void lookup() const { 61 int &v = (int &)k; 62 } 63 }; 64 } 65 66 namespace PR8795 { test(_CharT t)67 template <class _CharT> int test(_CharT t) 68 { 69 int data [] = { 70 sizeof(_CharT) > sizeof(char) 71 }; 72 return data[0]; 73 } 74 } 75 76 template<typename T> struct CastDependentIntToPointer { fCastDependentIntToPointer77 static void* f() { 78 T *x; 79 return ((void*)(((unsigned long)(x)|0x1ul))); 80 } 81 }; 82 83 // Regression test for crasher in r194540. 84 namespace PR10837 { 85 typedef void t(int); 86 template<typename> struct A { 87 void f(); 88 static t g; 89 }; 90 t *p; f()91 template<typename T> void A<T>::f() { 92 p = g; 93 } 94 template struct A<int>; 95 } 96 97 namespace PR18152 { 98 template<int N> struct A { 99 static const int n = {N}; 100 }; 101 template struct A<0>; 102 } 103