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