middle-end: Fix ifcvt predicate generation for masked function calls
[official-gcc.git] / gcc / testsuite / g++.dg / torture / pr54498.C
blob5d1e275dfcb4a3fe53ff327543b0d639a2a9bd53
1 // { dg-do run }
2 // { dg-additional-options "-fno-tree-sra" }
3 // { dg-skip-if "requires hosted libstdc++ for complex" { ! hostedlib } }
5 #include <complex>
7 using namespace std;
9 class bar_src {
10  public:
11   bar_src() : next(0) {}
12   virtual ~bar_src() { delete next; }
14   bar_src *next;
17 class foo_src : public bar_src {
18  public:
19   foo_src(double f, double fwidth, double s = 5.0);
20   virtual ~foo_src() {}
22  private:
23   double freq, width, peak_time, cutoff;
27 foo_src::foo_src(double f, double fwidth, double s) {
28   freq = f; width = 1/fwidth; cutoff = s*width; peak_time = cutoff;
31 complex<double> do_ft2(int i) __attribute__ ((noinline));
33 complex<double> do_ft2(int i) {
34   return i == 0 ? complex<double>(-491.697,887.05) : complex<double>(-491.692,887.026);
37 void foo(void) {
38   complex<double> prev_ft = 0.0, ft = 0.0;
39   for (int i=0; i < 2; i++) {
40     prev_ft = ft;
41     {
42       foo_src src(1.0, 1.0 / 20);
43       ft = do_ft2(i);
44     }
45     if (i > 0)
46       {
47         double a = abs(ft - prev_ft);
48         if (a < 0.024 || a > 0.025)
49           __builtin_abort ();
50       }
51   }
54 int main()
56   foo();
57   return 0;