1 /* PR c/48956: Test for diagnostics for implicit conversions involving complex
2 types. See also Wconversion-complex-c99.c.
4 These tests cover integer complex values (which are GNU extensions). */
6 /* { dg-do compile } */
7 /* { dg-skip-if "doubles are floats,ints are 16bits" { "avr-*-*" } } */
8 /* { dg-options " -std=gnu99 -Wconversion " } */
9 /* { dg-require-effective-target int32plus } */
10 /* { dg-require-effective-target double64plus } */
21 void fsic (int _Complex
);
22 void fuic (unsigned _Complex
);
23 void ffloatc (float _Complex
);
25 unsigned _Complex vuic
;
26 float _Complex vfloatc
;
28 /* Check implicit conversions of float complex-domain values to integer
29 complex-domain types. */
31 var_float_to_int (void)
33 double _Complex doublec
= 0.;
35 fsic (doublec
); /* { dg-warning "conversion" } */
36 fuic (doublec
); /* { dg-warning "conversion" } */
38 vsic
= doublec
; /* { dg-warning "conversion" } */
39 vuic
= doublec
; /* { dg-warning "conversion" } */
42 /* Check implicit conversions of integer complex-domain values to integer
45 var_complex_to_real (void)
48 unsigned _Complex uc
= 0;
49 unsigned long long _Complex ullc
= 0;
56 fsi (ic
); /* { dg-warning "conversion" } */
57 vsi
= ic
; /* { dg-warning "conversion" } */
58 fui (uc
); /* { dg-warning "conversion" } */
59 vui
= uc
; /* { dg-warning "conversion" } */
61 fuic (ullc
); /* { dg-warning "conversion" } */
62 vuic
= ullc
; /* { dg-warning "conversion" } */
64 fui (ic
); /* { dg-warning "conversion" } */
65 vui
= ic
; /* { dg-warning "conversion" } */
68 /* Check implicit conversions of float complex-domain constants to integer
71 const_float_to_int (void)
78 fsic (0.5 + 0.i
); /* { dg-warning "conversion" } */
79 vsic
= 0.5 + 0.i
; /* { dg-warning "conversion" } */
80 fuic (0.5 + 0.i
); /* { dg-warning "conversion" } */
83 /* Check implicit conversions of integer complex-domain constants to integer
86 const_complex_int_to_real_int (void)
93 fui (1 + 1i
); /* { dg-warning "conversion" } */
94 vui
= 1 + 1i
; /* { dg-warning "conversion" } */
96 fui (UINT_MAX
+ 1ull + 0i
); /* { dg-warning "conversion" } */
97 vui
= UINT_MAX
+ 1ull + 0i
; /* { dg-warning "conversion" } */
99 ffloat (UINT_MAX
+ 0i
); /* { dg-warning "conversion" } */
100 vfloat
= UINT_MAX
+ 0i
; /* { dg-warning "conversion" } */
104 const_complex_int_narrowing (void)
111 fuic (UINT_MAX
+ 1ull + 1i
); /* { dg-warning "conversion" } */
112 fuic ((UINT_MAX
+ 1ull) * 1i
); /* { dg-warning "conversion" } */
113 fuic ((UINT_MAX
+ 1ull) + (UINT_MAX
+ 1ull) * 1i
); /* { dg-warning "conversion" } */
115 vuic
= (UINT_MAX
+ 1ull) * 1i
; /* { dg-warning "conversion" } */
116 vuic
= (UINT_MAX
+ 1ull) + 1i
; /* { dg-warning "conversion" } */
117 vuic
= (UINT_MAX
+ 1ull) + (UINT_MAX
+ 1ull) * 1i
; /* { dg-warning "conversion" } */
119 ffloatc (UINT_MAX
* 1i
); /* { dg-warning "conversion" } */
120 ffloatc (UINT_MAX
+ 1i
); /* { dg-warning "conversion" } */
121 ffloatc (UINT_MAX
+ UINT_MAX
* 1i
); /* { dg-warning "conversion" } */
123 vfloatc
= UINT_MAX
* 1i
; /* { dg-warning "conversion" } */
124 vfloatc
= UINT_MAX
+ 1i
; /* { dg-warning "conversion" } */
125 vfloatc
= UINT_MAX
+ UINT_MAX
* 1i
; /* { dg-warning "conversion" } */