mirror of
https://github.com/ziglang/zig.git
synced 2025-01-23 18:31:44 +00:00
parent
c6605cba83
commit
ac7971122d
@ -12666,7 +12666,7 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira
|
||||
static TypeTableEntry *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira,
|
||||
IrInstructionCheckStatementIsVoid *instruction)
|
||||
{
|
||||
IrInstruction *statement_value = instruction->statement_value;
|
||||
IrInstruction *statement_value = instruction->statement_value->other;
|
||||
TypeTableEntry *statement_type = statement_value->value.type;
|
||||
if (type_is_invalid(statement_type))
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
|
@ -217,7 +217,7 @@ fn getString(st: &ElfStackTrace, offset: u64) -> %[]u8 {
|
||||
fn readAllocBytes(in_stream: &io.InStream, size: usize) -> %[]u8 {
|
||||
const buf = %return global_allocator.alloc(u8, size);
|
||||
%defer global_allocator.free(buf);
|
||||
if (size < %return in_stream.read(buf)) return error.Eof;
|
||||
if ((%return in_stream.read(buf)) < size) return error.Eof;
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -1348,6 +1348,37 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
|
||||
\\fn bar() -> i32 { 0 }
|
||||
, ".tmp_source.zig:2:8: error: expression value is ignored");
|
||||
|
||||
cases.add("ignored assert-err-ok return value",
|
||||
\\export fn foo() {
|
||||
\\ %%bar();
|
||||
\\}
|
||||
\\fn bar() -> %i32 { 0 }
|
||||
, ".tmp_source.zig:2:5: error: expression value is ignored");
|
||||
|
||||
cases.add("ignored statement value",
|
||||
\\export fn foo() {
|
||||
\\ 1;
|
||||
\\}
|
||||
, ".tmp_source.zig:2:5: error: expression value is ignored");
|
||||
|
||||
cases.add("ignored comptime statement value",
|
||||
\\export fn foo() {
|
||||
\\ comptime {1;}
|
||||
\\}
|
||||
, ".tmp_source.zig:2:15: error: expression value is ignored");
|
||||
|
||||
cases.add("ignored comptime value",
|
||||
\\export fn foo() {
|
||||
\\ comptime 1;
|
||||
\\}
|
||||
, ".tmp_source.zig:2:5: error: expression value is ignored");
|
||||
|
||||
cases.add("ignored defered statement value",
|
||||
\\export fn foo() {
|
||||
\\ defer {1;}
|
||||
\\}
|
||||
, ".tmp_source.zig:2:12: error: expression value is ignored");
|
||||
|
||||
cases.add("integer literal on a non-comptime var",
|
||||
\\export fn foo() {
|
||||
\\ var i = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user