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 from .double. to .float. changes value" } */
33 vfloat
= 3.1; /* { dg-warning "conversion from .double. to .float. changes value" } */
34 ffloat (3.1L); /* { dg-warning "conversion from .long double. to .float. changes value" } */
35 vfloat
= 3.1L; /* { dg-warning "conversion from .long double. to .float. changes value" } */
36 fdouble (3.1L); /* { dg-warning "conversion from .long double. to .double. changes value" "" { target large_long_double } } */
37 vdouble
= 3.1L; /* { dg-warning "conversion from .long double. to .double. changes value" "" { target large_long_double } } */
38 ffloat (vdouble
); /* { dg-warning "conversion from .double. to .float. may change value" } */
39 vfloat
= vdouble
; /* { dg-warning "conversion from .double. to .float. may change value" } */
40 ffloat (vlongdouble
); /* { dg-warning "conversion from .long double. to .float. may change value" } */
41 vfloat
= vlongdouble
; /* { dg-warning "conversion from .long double. to .float. may change value" } */
42 fdouble (vlongdouble
); /* { dg-warning "conversion from .long double. to .double. may change value" "" { target large_long_double } } */
43 vdouble
= vlongdouble
; /* { dg-warning "conversion from .long double. to .double. may change value" "" { target large_long_double } } */
45 fsi (3.1f
); /* { dg-warning "conversion from .float. to .int. changes value" } */
46 si
= 3.1f
; /* { dg-warning "conversion from .float. to .int. changes value" } */
47 fsi (3.1); /* { dg-warning "conversion from .double. to .int. changes value" } */
48 si
= 3.1; /* { dg-warning "conversion from .double. to .int. changes value" } */
49 fsi (d
); /* { dg-warning "conversion from .double. to .int. may change value" } */
50 si
= d
; /* { dg-warning "conversion from .double. to .int. may change value" } */
51 ffloat (INT_MAX
); /* { dg-warning "conversion from .int. to .float. changes value" } */
52 vfloat
= INT_MAX
; /* { dg-warning "conversion from .int. to .float. changes value" } */
53 ffloat (16777217); /* { dg-warning "conversion from .int. to .float. changes value from .16777217." } */
54 vfloat
= 16777217; /* { dg-warning "conversion from .int. to .float. changes value from .16777217." } */
56 sc
= bar
!= 0 ? 2.1 : 10; /* { dg-warning "conversion from .double. to .signed char. changes the value of .2\.1" } */
57 uc
= bar
!= 0 ? 2.1 : 10; /* { dg-warning "conversion from .double. to .unsigned char. changes the value of .2\.1" } */