1 /* Test for diagnostics for Wconversion for floating-point. */
3 /* { dg-do compile } */
4 /* { dg-options "-std=c99 -Wfloat-conversion" { target c } } */
5 /* { dg-options "-Wfloat-conversion" { target c++ } } */
6 /* { dg-require-effective-target large_double } */
7 /* { dg-require-effective-target int32plus } */
8 /* { dg-require-effective-target double64plus } */
13 long double vlongdouble
;
16 void fsi (signed int x
);
17 void fui (unsigned int x
);
18 void ffloat (float f
);
19 void fdouble (double d
);
20 void flongdouble (long double ld
);
32 ffloat (3.1); /* { dg-warning "conversion to 'float' alters 'double' constant value" } */
33 vfloat
= 3.1; /* { dg-warning "conversion to 'float' alters 'double' constant value" } */
34 ffloat (3.1L); /* { dg-warning "conversion to 'float' alters 'long double' constant value" } */
35 vfloat
= 3.1L; /* { dg-warning "conversion to 'float' alters 'long double' constant value" } */
36 fdouble (3.1L); /* { dg-warning "conversion to 'double' alters 'long double' constant value" "" { target large_long_double } } */
37 vdouble
= 3.1L; /* { dg-warning "conversion to 'double' alters 'long double' constant value" "" { target large_long_double } } */
38 ffloat (vdouble
); /* { dg-warning "conversion to 'float' from 'double' may alter its value" } */
39 vfloat
= vdouble
; /* { dg-warning "conversion to 'float' from 'double' may alter its value" } */
40 ffloat (vlongdouble
); /* { dg-warning "conversion to 'float' from 'long double' may alter its value" } */
41 vfloat
= vlongdouble
; /* { dg-warning "conversion to 'float' from 'long double' may alter its value" } */
42 fdouble (vlongdouble
); /* { dg-warning "conversion to 'double' from 'long double' may alter its value" "" { target large_long_double } } */
43 vdouble
= vlongdouble
; /* { dg-warning "conversion to 'double' from 'long double' may alter its value" "" { target large_long_double } } */
45 fsi (3.1f
); /* { dg-warning "conversion to 'int' alters 'float' constant value" } */
46 si
= 3.1f
; /* { dg-warning "conversion to 'int' alters 'float' constant value" } */
47 fsi (3.1); /* { dg-warning "conversion to 'int' alters 'double' constant value" } */
48 si
= 3.1; /* { dg-warning "conversion to 'int' alters 'double' constant value" } */
49 fsi (d
); /* { dg-warning "conversion to 'int' from 'double' may alter its value" } */
50 si
= d
; /* { dg-warning "conversion to 'int' from 'double' may alter its value" } */
51 ffloat (INT_MAX
); /* { dg-warning "conversion to 'float' alters 'int' constant value" } */
52 vfloat
= INT_MAX
; /* { dg-warning "conversion to 'float' alters 'int' constant value" } */
53 ffloat (16777217); /* { dg-warning "conversion to 'float' alters 'int' constant value" } */
54 vfloat
= 16777217; /* { dg-warning "conversion to 'float' alters 'int' constant value" } */
56 sc
= bar
!= 0 ? 2.1 : 10; /* { dg-warning "conversion to 'signed char' alters 'double' constant value" } */
57 uc
= bar
!= 0 ? 2.1 : 10; /* { dg-warning "conversion to 'unsigned char' alters 'double' constant value" } */