Skip to content

Commit

Permalink
Parser: make unary minus work with float values
Browse files Browse the repository at this point in the history
  • Loading branch information
ehaas committed Feb 26, 2024
1 parent 59fd131 commit 42bdd90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6934,7 +6934,7 @@ fn unExpr(p: *Parser) Error!Result {
try p.errStr(.invalid_argument_un, tok, try p.typeStr(operand.ty));

try operand.usualUnaryConversion(p, tok);
if (operand.val.is(.int, p.comp)) {
if (operand.val.is(.int, p.comp) or operand.val.is(.float, p.comp)) {
_ = try operand.val.sub(Value.zero, operand.val, operand.ty, p.comp);
} else {
operand.val = .{};
Expand Down
2 changes: 2 additions & 0 deletions test/cases/float values.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_Static_assert(-1.0 - 1.0 == -2.0, "");
_Static_assert(-2.0f == -2.0, "");

0 comments on commit 42bdd90

Please sign in to comment.