aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/builtins-5.c
blob: a056812446da8af728d5c69454b70a1eaa98cb1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* Copyright (C) 2003  Free Software Foundation.

   Verify that built-in math function constant folding of constant
   arguments is correctly performed by the by the compiler.

   Written by Roger Sayle, 20th February 2003.  */

/* { dg-do link } */
/* { dg-options "-O2" } */

extern void link_error(void);

void test(double x)
{
  if (pow (x, 0.0) != 1.0)
    link_error ();
  if (pow (1.0, x) != 1.0)
    link_error ();
}

void testf(float x)
{
  if (powf (x, 0.0f) != 1.0f)
    link_error ();
  if (powf (1.0f, x) != 1.0f)
    link_error ();
}

void testl(long double x)
{
  if (powl (x, 0.0l) != 1.0l)
    link_error ();
  if (powl (1.0l, x) != 1.0l)
    link_error ();
}

int main()
{
  test (0.0);
  testf (0.0f);
  testl (0.0l);

  return 0;
}