c++: constantness of call to function pointer [PR111703]
[official-gcc.git] / gcc / testsuite / g++.dg / torture / pr78507.C
blob6d6bd31c57108d6bddc4a596631944e36dadeba7
1 // PR middle-end/78507
2 // { dg-do compile }
3 // { dg-additional-options "-Wno-return-type" }
5 struct A {
6   template <typename _Iterator1, typename _Iterator2>
7   int operator()(_Iterator1, _Iterator2);
8 };
9 struct B {
10   template <typename _BI1, typename _BI2>
11   static _BI2 __copy_move_b(_BI1 p1, _BI2 p2) {
12     _BI1 a;
13     long b = p1 - a;
14     for (; b > 0; --b)
15       *--p2 = *--p1;
16   }
18 template <int, typename _BI1, typename _BI2>
19 void __copy_move_backward_a(_BI1 p1, _BI2 p2) {
20   B::__copy_move_b(p1, p2);
22 template <int, typename _BI1, typename _BI2>
23 void __copy_move_backward_a2(_BI1 p1, _BI2 p2) {
24   __copy_move_backward_a<0>(p1, p2);
26 template <typename _BI1, typename _BI2> void move_backward(_BI1 p1, _BI2 p2) {
27   __copy_move_backward_a2<0>(p1, p2);
29 template <typename _RandomAccessIterator, typename _Compare>
30 void __insertion_sort(_RandomAccessIterator, _Compare p2) {
31   for (_RandomAccessIterator c;; ++c)
32     if (p2(0, 0))
33       move_backward(c, c + 1);
35 template <typename _RandomAccessIterator, typename _Compare>
36 void __final_insertion_sort(_RandomAccessIterator, _Compare p2) {
37   _RandomAccessIterator d;
38   __insertion_sort(d, p2);
40 template <typename _RandomAccessIterator, typename _Compare>
41 void __sort(_RandomAccessIterator p1, _Compare p2) {
42   __final_insertion_sort(p1, p2);
44 template <typename _RandomAccessIterator, typename _Compare>
45 void sort(_RandomAccessIterator, _RandomAccessIterator p2, _Compare) {
46   A e;
47   __sort(p2, e);
49 struct C {
50   struct D {
51     int DwarfRegNum;
52   };
53   int parseRegisterLiveOutMask() const;
55 int C::parseRegisterLiveOutMask() const {
56   D f, g;
57   sort(&f, &g, [] {});