OSDN Git Service

* gcc.dg/vect/vect-105.c: Prevent compiler from hoisting abort
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / Wconversion-real.c
1 /* Test for diagnostics for Wconversion for floating-point.  */
2
3 /* { dg-do compile } */
4 /* { dg-skip-if "doubles are floats" { "avr-*-*" } { "*" } { "" } } */
5 /* { dg-options "-std=c99 -Wconversion" } */
6
7 float  vfloat;
8 double vdouble;
9 long double vlongdouble;
10
11 void ffloat (float f);
12 void fdouble (double d);
13 void flongdouble (long double ld);
14
15 void h (void)
16 {
17   float f = 0;
18   double d = 0;
19   long double ld = 0;
20
21   ffloat (3.1); /* { dg-warning "conversion" } */
22   vfloat = 3.1; /* { dg-warning "conversion" } */
23   ffloat (3.1L); /* { dg-warning "conversion" } */
24   vfloat = 3.1L;  /* { dg-warning "conversion" } */
25   fdouble (3.1L); /* { dg-warning "conversion" "" { target large_long_double } } */
26   vdouble = 3.1L; /* { dg-warning "conversion" "" { target large_long_double } } */
27   ffloat (vdouble); /* { dg-warning "conversion" } */
28   vfloat = vdouble; /* { dg-warning "conversion" } */
29   ffloat (vlongdouble); /* { dg-warning "conversion" } */
30   vfloat = vlongdouble; /* { dg-warning "conversion" } */
31   fdouble (vlongdouble); /* { dg-warning "conversion" "" { target large_long_double } } */
32   vdouble = vlongdouble; /* { dg-warning "conversion" "" { target large_long_double } } */
33
34
35   ffloat ((float) 3.1); 
36   vfloat = (float) 3.1;
37   ffloat ((float) 3.1L);
38   vfloat = (float) 3.1L; 
39   fdouble ((double) 3.1L); 
40   vdouble = (double) 3.1L; 
41   ffloat ((float) vdouble); 
42   vfloat = (float) vdouble; 
43   ffloat ((float) vlongdouble); 
44   vfloat = (float) vlongdouble;
45   fdouble ((double) vlongdouble);
46   vdouble = (double) vlongdouble;
47
48
49   ffloat (3.0);
50   vfloat = 3.0;
51   ffloat (3.1f);
52   vfloat = 3.1f;
53   ffloat (0.25L);
54   vfloat = 0.25L;
55
56
57   fdouble (3.0);
58   vdouble = 3.0;
59   fdouble (3.1f);
60   vdouble = 3.1f;
61   fdouble (0.25L);
62   vdouble = 0.25L;
63
64   flongdouble (3.0);
65   vlongdouble = 3.0;
66   flongdouble (3.1f);
67   vlongdouble = 3.1f;
68   flongdouble (0.25L);
69   vlongdouble = 0.25L;
70
71   ffloat (f);
72   vfloat = f;
73   fdouble (f);
74   vdouble = f;
75   fdouble (d);
76   vdouble = d;
77   flongdouble (f);
78   vlongdouble = f;
79   flongdouble (d);
80   vlongdouble = d;
81   flongdouble (ld);
82   vlongdouble = ld;
83 }