ipa-cp: Perform operations in the appropriate types (PR 118097)
[gcc.git] / gcc / testsuite / g++.dg / template / friend80.C
blob5c417e12dd0c31e6da0c8e93e849a4b2af8f4fac
1 // PR c++/112288
2 // { dg-do compile { target c++11 } }
4 template<class T>
5 struct slot {
6   template<class U>
7   friend constexpr bool slot_allocated(slot<T>, U);
8 };
10 template<class T>
11 struct allocate_slot {
12   template<class U>
13   friend constexpr bool slot_allocated(slot<T>, U) { return true; }
16 template<class T, bool = slot_allocated(slot<T>{}, 42)>
17 constexpr int next(int) { return 1; }
19 template<class T>
20 constexpr int next(...) { return (allocate_slot<T>{}, 0); }
22 // slot_allocated<slot<int>, int>() not defined yet
23 static_assert(next<int>(0) == 0, "");
24 // now it's defined, need to make existing spec point to defn or else ICE
25 static_assert(next<int>(0) == 1, "");