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