| ... | @@ -1205,7 +1205,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1205,7 +1205,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1205 | \\#define baz 1e1 | 1205 | \\#define baz 1e1 |
| 1206 | \\#define BAZ 42e-3f | 1206 | \\#define BAZ 42e-3f |
| 1207 | \\#define foobar -73.L | 1207 | \\#define foobar -73.L |
| 1208 | , &[_][]const u8{ | 1208 | \\extern const float my_float = 1.0f; |
| | 1209 | \\extern const double my_double = 1.0; |
| | 1210 | \\extern const long double my_longdouble = 1.0l; |
| | 1211 | , &([_][]const u8{ |
| 1209 | "pub const foo = @as(f32, 3.14);", | 1212 | "pub const foo = @as(f32, 3.14);", |
| 1210 | "pub const bar = @as(c_longdouble, 16.0e-2);", | 1213 | "pub const bar = @as(c_longdouble, 16.0e-2);", |
| 1211 | "pub const FOO = @as(f64, 0.12345);", | 1214 | "pub const FOO = @as(f64, 0.12345);", |
| ... | @@ -1213,7 +1216,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1213,7 +1216,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1213 | "pub const baz = @as(f64, 1e1);", | 1216 | "pub const baz = @as(f64, 1e1);", |
| 1214 | "pub const BAZ = @as(f32, 42e-3);", | 1217 | "pub const BAZ = @as(f32, 42e-3);", |
| 1215 | "pub const foobar = -@as(c_longdouble, 73.0);", | 1218 | "pub const foobar = -@as(c_longdouble, 73.0);", |
| 1216 | }); | 1219 | "pub export const my_float: f32 = 1.0;", |
| | 1220 | "pub export const my_double: f64 = 1.0;", |
| | 1221 | } ++ if (@bitSizeOf(c_longdouble) != 64) .{ |
| | 1222 | // TODO properly translate non-64-bit long doubles |
| | 1223 | "source.h:10:42: warning: unsupported floating point constant format", |
| | 1224 | "source.h:10:26: warning: unable to translate variable initializer, demoted to extern", |
| | 1225 | "pub extern const my_longdouble: c_longdouble;", |
| | 1226 | } else .{ |
| | 1227 | "pub export const my_longdouble: c_longdouble = 1.0;", |
| | 1228 | })); |
| 1217 | | 1229 | |
| 1218 | cases.add("macro defines hexadecimal float", | 1230 | cases.add("macro defines hexadecimal float", |
| 1219 | \\#define FOO 0xf7p38 | 1231 | \\#define FOO 0xf7p38 |