|
| 1 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir |
| 2 | +// |
| 3 | +// XFAIL: * |
| 4 | +// |
| 5 | +// Issue: Complex template metaprogramming with __builtin_is_constant_evaluated |
| 6 | +// |
| 7 | +// When using advanced template metaprogramming involving: |
| 8 | +// - Template aliases with variadic templates |
| 9 | +// - decltype expressions in template parameters |
| 10 | +// - __builtin_is_constant_evaluated() in constexpr context |
| 11 | +// - Complex member function template instantiation chains |
| 12 | +// CIR fails during constant expression evaluation or template instantiation. |
| 13 | + |
| 14 | +template <typename a> struct b { |
| 15 | + typedef a c; |
| 16 | +}; |
| 17 | +template <typename a> class d { |
| 18 | +public: |
| 19 | + typedef a c; |
| 20 | +}; |
| 21 | +template <typename a> using ad = d<a>::c; |
| 22 | +template <typename...> struct g; |
| 23 | +struct i { |
| 24 | + template <typename, typename e> using f = decltype(e()); |
| 25 | + template <typename a, typename e> static b<ad<f<a, e>>> k(int); |
| 26 | +}; |
| 27 | +template <typename h> struct l : i { |
| 28 | + using c = decltype(k<int, h>(0)); |
| 29 | +}; |
| 30 | +template <typename j, typename h> struct g<j, h> : l<h>::c {}; |
| 31 | +template <typename... a> using ah = g<a...>::c; |
| 32 | +class m; |
| 33 | +class n { |
| 34 | + void o(m &) const; |
| 35 | +}; |
| 36 | +template <typename = void> struct al; |
| 37 | +template <typename a> struct al<a *> { |
| 38 | + void operator()(a *, a *) { |
| 39 | + if (__builtin_is_constant_evaluated()) |
| 40 | + ; |
| 41 | + } |
| 42 | +}; |
| 43 | +template <> struct al<> { |
| 44 | + template <typename a, typename e> void operator()(a p, e *p2) { |
| 45 | + al<ah<a, e *>>{}(p, p2); |
| 46 | + } |
| 47 | +}; |
| 48 | +class q { |
| 49 | + void *aq; |
| 50 | + void *ar; |
| 51 | + template <class au> void r(au, int, long) { |
| 52 | + al a; |
| 53 | + a(aq, ar); |
| 54 | + } |
| 55 | +}; |
| 56 | +template <typename> class s : q { |
| 57 | + int az; |
| 58 | + long ba; |
| 59 | + |
| 60 | +public: |
| 61 | + void t() { r(this, az, ba); } |
| 62 | +}; |
| 63 | +class m { |
| 64 | + s<int> bd; |
| 65 | + |
| 66 | +public: |
| 67 | + void m_fn5() { bd.t(); } |
| 68 | +}; |
| 69 | +void n::o(m &p) const { p.m_fn5(); } |
0 commit comments