aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/dfp/warn-abs-2.c
blob: 403b0394298e12180505ab34f0c39cd323d49b9d (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
/* { dg-do compile } */
/* { dg-options "-Wabsolute-value" } */

#include <stdlib.h>
#include <complex.h>
#include <math.h>

void tst_decimal (_Decimal32 *p32, _Decimal64 *p64, _Decimal128 *p128)
{
  *p32 = abs(*p32);       /* { dg-warning "using integer absolute value function" } */
  *p64 = fabs(*p64);      /* { dg-warning "using floating-point absolute value function" } */
  *p128 = cabsl(*p128);   /* { dg-warning "using complex absolute value function" } */
}

void tst_notdecimal (int *pi, double *pd, long double *pld, complex double *pc)
{
  *pi = __builtin_fabsd32 (*pi);   /* { dg-warning "using decimal floating-point absolute value function" } */
  *pd = __builtin_fabsd64 (*pd);   /* { dg-warning "using decimal floating-point absolute value function" } */
  *pld = __builtin_fabsd64 (*pld); /* { dg-warning "using decimal floating-point absolute value function" } */
  *pc = __builtin_fabsd128 (*pc);  /* { dg-warning "using decimal floating-point absolute value function" } */
}

void
test_size  (_Decimal64 *p64, _Decimal128 *p128)
{
  *p64 = __builtin_fabsd32 (*p64);   /* { dg-warning "may cause truncation of value" } */
  *p128 = __builtin_fabsd64 (*p128); /* { dg-warning "may cause truncation of value" } */
}