1// RUN: %clang_cc1 %s -ast-print -o - -chain-include %s -chain-include %s 2// RUN: %clang_cc1 %s -ast-print -o - -fmodules -chain-include %s -chain-include %s 3 4#if !defined(PASS1) 5#define PASS1 6 7template <class T> class TClass; 8 9namespace NS { 10 template <class X, class Y> TClass<X> problematic(X * ptr, const TClass<Y> &src); 11 12 template <class T> 13 class TBaseClass 14 { 15 protected: 16 template <class X, class Y> friend TClass<X> problematic(X * ptr, const TClass<Y> &src); 17 }; 18} 19 20template <class T> 21class TClass: public NS::TBaseClass<T> 22{ 23public: 24 inline TClass() { } 25}; 26 27 28namespace NS { 29 template <class X, class T> 30 TClass<X> problematic(X *ptr, const TClass<T> &src); 31} 32 33template <class X, class T> 34TClass<X> unconst(const TClass<T> &src); 35 36#elif !defined(PASS2) 37#define PASS2 38 39namespace std { 40class s {}; 41} 42 43 44typedef TClass<std::s> TStr; 45 46struct crash { 47 TStr str; 48 49 crash(const TClass<std::s> p) 50 { 51 unconst<TStr>(p); 52 } 53}; 54 55#else 56 57void f() { 58 const TStr p; 59 crash c(p); 60} 61 62#endif 63