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