mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
translate-c: cast unsuffixed floats to f64
This commit is contained in:
parent
476b946802
commit
44f8714dfb
@ -5783,11 +5783,9 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!Node {
|
||||
}
|
||||
}
|
||||
|
||||
if (suffix == .none)
|
||||
return transCreateNodeNumber(c, lit_bytes, .float);
|
||||
|
||||
const type_node = try Tag.type.create(c.arena, switch (suffix) {
|
||||
.f => "f32",
|
||||
.none => "f64",
|
||||
.l => "c_longdouble",
|
||||
else => unreachable,
|
||||
});
|
||||
|
||||
@ -1216,9 +1216,9 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
, &[_][]const u8{
|
||||
"pub const foo = @as(f32, 3.14);",
|
||||
"pub const bar = @as(c_longdouble, 16.0e-2);",
|
||||
"pub const FOO = 0.12345;",
|
||||
"pub const BAR = 0.12345;",
|
||||
"pub const baz = 1e1;",
|
||||
"pub const FOO = @as(f64, 0.12345);",
|
||||
"pub const BAR = @as(f64, 0.12345);",
|
||||
"pub const baz = @as(f64, 1e1);",
|
||||
"pub const BAZ = @as(f32, 42e-3);",
|
||||
"pub const foobar = -@as(c_longdouble, 73.0);",
|
||||
});
|
||||
@ -1230,10 +1230,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\#define BAZ -0x.0a5dp+12
|
||||
\\#define FOOBAZ 0xfE.P-1l
|
||||
, &[_][]const u8{
|
||||
"pub const FOO = 0xf7p38;",
|
||||
"pub const FOO = @as(f64, 0xf7p38);",
|
||||
"pub const BAR = -@as(f32, 0x8F.BP5);",
|
||||
"pub const FOOBAR = 0x0P+0;",
|
||||
"pub const BAZ = -0x0.0a5dp+12;",
|
||||
"pub const FOOBAR = @as(f64, 0x0P+0);",
|
||||
"pub const BAZ = -@as(f64, 0x0.0a5dp+12);",
|
||||
"pub const FOOBAZ = @as(c_longdouble, 0xfE.0P-1);",
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user