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 7 template <class T> class TClass; 8 9 namespace 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 20 template <class T> 21 class TClass: public NS::TBaseClass<T> 22 { 23 public: TClass()24 inline TClass() { } 25 }; 26 27 28 namespace NS { 29 template <class X, class T> 30 TClass<X> problematic(X *ptr, const TClass<T> &src); 31 } 32 33 template <class X, class T> 34 TClass<X> unconst(const TClass<T> &src); 35 36 #elif !defined(PASS2) 37 #define PASS2 38 39 namespace std { 40 class s {}; 41 } 42 43 44 typedef TClass<std::s> TStr; 45 46 struct crash { 47 TStr str; 48 crashcrash49 crash(const TClass<std::s> p) 50 { 51 unconst<TStr>(p); 52 } 53 }; 54 55 #else 56 f()57void f() { 58 const TStr p; 59 crash c(p); 60 } 61 62 #endif 63