Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / gcc.dg / warn-abs-1.c
blobc016ff620c4cee4259f7174988862a6e1163191d
1 /* { dg-do compile } */
2 /* { dg-options "-Wabsolute-value" } */
4 #include <stdlib.h>
5 #include <inttypes.h>
6 #include <math.h>
7 #include <complex.h>
9 void
10 tst_unsigned (unsigned *pu, unsigned long *pl, unsigned long long *pll,
11 uintmax_t *pm)
13 *pu = abs (*pu); /* { dg-warning "taking the absolute value of unsigned type" } */
14 *pl = labs (*pl); /* { dg-warning "taking the absolute value of unsigned type" } */
15 *pll = llabs (*pll); /* { dg-warning "taking the absolute value of unsigned type" } */
16 *pm = imaxabs (*pm); /* { dg-warning "taking the absolute value of unsigned type" } */
19 void
20 test_int_size (long long *pll)
22 *pll = abs (*pll); /* { dg-warning "may cause truncation of value" } */
23 *pll = abs ((int) *pll);
26 void
27 tst_notint (float *pf, double *pd, _Complex double *pc)
29 *pf = abs (*pf); /* { dg-warning "using integer absolute value function" } */
30 *pd = labs (*pd); /* { dg-warning "using integer absolute value function" } */
31 *pc = abs (*pc); /* { dg-warning "using integer absolute value function" } */
34 void
35 tst_notfloat (int *pi, long *pl, complex double *pc)
37 *pi = fabsf (*pi); /* { dg-warning "using floating point absolute value function" } */
38 *pl = fabs (*pl); /* { dg-warning "using floating point absolute value function" } */
39 *pc = fabs (*pc); /* { dg-warning "using floating point absolute value function" } */
42 void
43 tst_float_size (double *pd, long double *pld)
45 *pd = fabsf (*pd); /* { dg-warning "may cause truncation of value" } */
46 *pld = fabs (*pld); /* { dg-warning "may cause truncation of value" "fabs trunc" { target { large_long_double } } } */
47 *pld = fabs ((double) *pld);
50 void tst_notcomplex (int *pi, long *pl, long double *pld)
52 *pi = cabs (*pi); /* { dg-warning "using complex absolute value function" } */
53 *pl = cabs (*pl); /* { dg-warning "using complex absolute value function" } */
54 *pld = cabsl (*pld);/* { dg-warning "using complex absolute value function" } */
57 void tst_cplx_size (complex double *pcd, complex long double *pcld)
59 *pcd = cabsf (*pcd); /* { dg-warning "may cause truncation of value" } */
60 *pcld = cabs (*pcld); /* { dg-warning "may cause truncation of value" "cabs trunc" { target { large_long_double } } } */
61 *pcld = cabs ((complex double) *pcld);