diff options
| author | travisstaloch <twostepted@gmail.com> | 2021-10-15 10:56:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-15 13:56:27 -0400 |
| commit | 16ac034a32e8c8feced3ee67f84ff14767404b76 (patch) | |
| tree | f3d11a635720422f30a31b21cb735a7cb04c8c64 /test/compile_errors.zig | |
| parent | 411e9ca4ade243344f358b14151e87e2334e76a0 (diff) | |
| download | zig-16ac034a32e8c8feced3ee67f84ff14767404b76.tar.gz zig-16ac034a32e8c8feced3ee67f84ff14767404b76.zip | |
Sat shl neg rhs (#9949)
* saturating shl - check for negative rhs at comptime
- adds expected compile_errors case for negative rhs
* add expected compile error for sat shl assign
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index ab0d504e68..877ceec85d 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -8869,6 +8869,25 @@ pub fn addCases(ctx: *TestContext) !void { "error: invalid operands to binary expression: 'f32' and 'f32'", }); + ctx.objErrStage1("saturating shl does not allow negative rhs at comptime", + \\pub fn main() !void { + \\ _ = @as(i32, 1) <<| @as(i32, -2); + \\} + , &[_][]const u8{ + "error: shift by negative value -2", + }); + + ctx.objErrStage1("saturating shl assign does not allow negative rhs at comptime", + \\pub fn main() !void { + \\ comptime { + \\ var x = @as(i32, 1); + \\ x <<|= @as(i32, -2); + \\ } + \\} + , &[_][]const u8{ + "error: shift by negative value -2", + }); + ctx.objErrStage1("undeclared identifier in unanalyzed branch", \\export fn a() void { \\ if (false) { |
