authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-26 12:43:36-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-26 12:43:36-04:00
log73a7747a9cfb180a92fa0d98f9387d5ad1f47fd2
tree5b26647eecc6c7f709464678e48a300a8789d473
parent6569bfc85e7de5229dd5b665e84070970d28653d
signaturelock-open Commit is signed but in an unrecognized format.

fix some compile error regressions


5 files changed, 37 insertions(+), 26 deletions(-)

src/all_types.hpp+7
...@@ -53,6 +53,13 @@ enum PtrLen {...@@ -53,6 +53,13 @@ enum PtrLen {
53 PtrLenC,53 PtrLenC,
54};54};
5555
56enum UndefAllowed {
57 UndefOk,
58 UndefBad,
59 LazyOkNoUndef,
60 LazyOk,
61};
62
56enum X64CABIClass {63enum X64CABIClass {
57 X64CABIClass_Unknown,64 X64CABIClass_Unknown,
58 X64CABIClass_MEMORY,65 X64CABIClass_MEMORY,
src/analyze.cpp+18-11
...@@ -59,6 +59,7 @@ ErrorMsg *add_token_error(CodeGen *g, ZigType *owner, Token *token, Buf *msg) {...@@ -59,6 +59,7 @@ ErrorMsg *add_token_error(CodeGen *g, ZigType *owner, Token *token, Buf *msg) {
59 root_struct->source_code, root_struct->line_offsets, msg);59 root_struct->source_code, root_struct->line_offsets, msg);
6060
61 g->errors.append(err);61 g->errors.append(err);
62 g->trace_err = err;
62 return err;63 return err;
63}64}
6465
...@@ -1793,7 +1794,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {...@@ -1793,7 +1794,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
1793 if (struct_type->data.structure.resolve_loop_flag_other) {1794 if (struct_type->data.structure.resolve_loop_flag_other) {
1794 if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) {1795 if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) {
1795 struct_type->data.structure.resolve_status = ResolveStatusInvalid;1796 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
1796 g->trace_err = add_node_error(g, decl_node,1797 add_node_error(g, decl_node,
1797 buf_sprintf("struct '%s' depends on its own size", buf_ptr(&struct_type->name)));1798 buf_sprintf("struct '%s' depends on its own size", buf_ptr(&struct_type->name)));
1798 }1799 }
1799 return ErrorSemanticAnalyzeFail;1800 return ErrorSemanticAnalyzeFail;
...@@ -1947,7 +1948,7 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) {...@@ -1947,7 +1948,7 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) {
1947 if (union_type->data.unionation.resolve_loop_flag_other) {1948 if (union_type->data.unionation.resolve_loop_flag_other) {
1948 if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) {1949 if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) {
1949 union_type->data.unionation.resolve_status = ResolveStatusInvalid;1950 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
1950 g->trace_err = add_node_error(g, decl_node,1951 add_node_error(g, decl_node,
1951 buf_sprintf("union '%s' depends on its own alignment", buf_ptr(&union_type->name)));1952 buf_sprintf("union '%s' depends on its own alignment", buf_ptr(&union_type->name)));
1952 }1953 }
1953 return ErrorSemanticAnalyzeFail;1954 return ErrorSemanticAnalyzeFail;
...@@ -2058,7 +2059,7 @@ static Error resolve_union_type(CodeGen *g, ZigType *union_type) {...@@ -2058,7 +2059,7 @@ static Error resolve_union_type(CodeGen *g, ZigType *union_type) {
2058 if (union_type->data.unionation.resolve_loop_flag_other) {2059 if (union_type->data.unionation.resolve_loop_flag_other) {
2059 if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) {2060 if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) {
2060 union_type->data.unionation.resolve_status = ResolveStatusInvalid;2061 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
2061 g->trace_err = add_node_error(g, decl_node,2062 add_node_error(g, decl_node,
2062 buf_sprintf("union '%s' depends on its own size", buf_ptr(&union_type->name)));2063 buf_sprintf("union '%s' depends on its own size", buf_ptr(&union_type->name)));
2063 }2064 }
2064 return ErrorSemanticAnalyzeFail;2065 return ErrorSemanticAnalyzeFail;
...@@ -2160,7 +2161,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) {...@@ -2160,7 +2161,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) {
2160 if (enum_type->data.enumeration.resolve_loop_flag) {2161 if (enum_type->data.enumeration.resolve_loop_flag) {
2161 if (enum_type->data.enumeration.resolve_status != ResolveStatusInvalid) {2162 if (enum_type->data.enumeration.resolve_status != ResolveStatusInvalid) {
2162 enum_type->data.enumeration.resolve_status = ResolveStatusInvalid;2163 enum_type->data.enumeration.resolve_status = ResolveStatusInvalid;
2163 g->trace_err = add_node_error(g, decl_node,2164 add_node_error(g, decl_node,
2164 buf_sprintf("enum '%s' depends on itself",2165 buf_sprintf("enum '%s' depends on itself",
2165 buf_ptr(&enum_type->name)));2166 buf_ptr(&enum_type->name)));
2166 }2167 }
...@@ -2337,7 +2338,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) {...@@ -2337,7 +2338,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) {
2337 if (struct_type->data.structure.resolve_loop_flag_zero_bits) {2338 if (struct_type->data.structure.resolve_loop_flag_zero_bits) {
2338 if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) {2339 if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) {
2339 struct_type->data.structure.resolve_status = ResolveStatusInvalid;2340 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2340 g->trace_err = add_node_error(g, decl_node,2341 add_node_error(g, decl_node,
2341 buf_sprintf("struct '%s' depends on itself",2342 buf_sprintf("struct '%s' depends on itself",
2342 buf_ptr(&struct_type->name)));2343 buf_ptr(&struct_type->name)));
2343 }2344 }
...@@ -2462,7 +2463,7 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) {...@@ -2462,7 +2463,7 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) {
2462 if (struct_type->data.structure.resolve_loop_flag_other) {2463 if (struct_type->data.structure.resolve_loop_flag_other) {
2463 if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) {2464 if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) {
2464 struct_type->data.structure.resolve_status = ResolveStatusInvalid;2465 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2465 g->trace_err = add_node_error(g, decl_node,2466 add_node_error(g, decl_node,
2466 buf_sprintf("struct '%s' depends on its own alignment", buf_ptr(&struct_type->name)));2467 buf_sprintf("struct '%s' depends on its own alignment", buf_ptr(&struct_type->name)));
2467 }2468 }
2468 return ErrorSemanticAnalyzeFail;2469 return ErrorSemanticAnalyzeFail;
...@@ -2530,7 +2531,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {...@@ -2530,7 +2531,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
2530 if (union_type->data.unionation.resolve_loop_flag_zero_bits) {2531 if (union_type->data.unionation.resolve_loop_flag_zero_bits) {
2531 if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) {2532 if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) {
2532 union_type->data.unionation.resolve_status = ResolveStatusInvalid;2533 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
2533 g->trace_err = add_node_error(g, decl_node,2534 add_node_error(g, decl_node,
2534 buf_sprintf("union '%s' depends on itself",2535 buf_sprintf("union '%s' depends on itself",
2535 buf_ptr(&union_type->name)));2536 buf_ptr(&union_type->name)));
2536 }2537 }
...@@ -3423,7 +3424,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {...@@ -3423,7 +3424,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
3423 ZigType *explicit_type = nullptr;3424 ZigType *explicit_type = nullptr;
3424 if (var_decl->type) {3425 if (var_decl->type) {
3425 if (tld_var->analyzing_type) {3426 if (tld_var->analyzing_type) {
3426 g->trace_err = add_node_error(g, var_decl->type,3427 add_node_error(g, var_decl->type,
3427 buf_sprintf("type of '%s' depends on itself", buf_ptr(tld_var->base.name)));3428 buf_sprintf("type of '%s' depends on itself", buf_ptr(tld_var->base.name)));
3428 explicit_type = g->builtin_types.entry_invalid;3429 explicit_type = g->builtin_types.entry_invalid;
3429 } else {3430 } else {
...@@ -4001,6 +4002,13 @@ static void resolve_async_fn_frame(CodeGen *g, ZigFn *fn) {...@@ -4001,6 +4002,13 @@ static void resolve_async_fn_frame(CodeGen *g, ZigFn *fn) {
4001 ZigType *frame_type = get_fn_frame_type(g, fn);4002 ZigType *frame_type = get_fn_frame_type(g, fn);
4002 Error err;4003 Error err;
4003 if ((err = type_resolve(g, frame_type, ResolveStatusSizeKnown))) {4004 if ((err = type_resolve(g, frame_type, ResolveStatusSizeKnown))) {
4005 if (g->trace_err != nullptr && frame_type->data.frame.resolve_loop_src_node != nullptr &&
4006 !frame_type->data.frame.reported_loop_err)
4007 {
4008 frame_type->data.frame.reported_loop_err = true;
4009 g->trace_err = add_error_note(g, g->trace_err, frame_type->data.frame.resolve_loop_src_node,
4010 buf_sprintf("when analyzing type '%s' here", buf_ptr(&frame_type->name)));
4011 }
4004 fn->anal_state = FnAnalStateInvalid;4012 fn->anal_state = FnAnalStateInvalid;
4005 return;4013 return;
4006 }4014 }
...@@ -5406,8 +5414,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {...@@ -5406,8 +5414,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
54065414
5407 if (frame_type->data.frame.resolve_loop_type != nullptr) {5415 if (frame_type->data.frame.resolve_loop_type != nullptr) {
5408 if (!frame_type->data.frame.reported_loop_err) {5416 if (!frame_type->data.frame.reported_loop_err) {
5409 frame_type->data.frame.reported_loop_err = true;5417 add_node_error(g, fn->proto_node,
5410 g->trace_err = add_node_error(g, fn->proto_node,
5411 buf_sprintf("'%s' depends on itself", buf_ptr(&frame_type->name)));5418 buf_sprintf("'%s' depends on itself", buf_ptr(&frame_type->name)));
5412 }5419 }
5413 return ErrorSemanticAnalyzeFail;5420 return ErrorSemanticAnalyzeFail;
...@@ -5424,7 +5431,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {...@@ -5424,7 +5431,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
5424 return ErrorSemanticAnalyzeFail;5431 return ErrorSemanticAnalyzeFail;
5425 break;5432 break;
5426 case FnAnalStateProbing: {5433 case FnAnalStateProbing: {
5427 g->trace_err = add_node_error(g, fn->proto_node,5434 add_node_error(g, fn->proto_node,
5428 buf_sprintf("cannot resolve '%s': function not fully analyzed yet",5435 buf_sprintf("cannot resolve '%s': function not fully analyzed yet",
5429 buf_ptr(&frame_type->name)));5436 buf_ptr(&frame_type->name)));
5430 return ErrorSemanticAnalyzeFail;5437 return ErrorSemanticAnalyzeFail;
src/ir.cpp+5-8
...@@ -152,12 +152,6 @@ struct ConstCastBadAllowsZero {...@@ -152,12 +152,6 @@ struct ConstCastBadAllowsZero {
152};152};
153153
154154
155enum UndefAllowed {
156 UndefOk,
157 UndefBad,
158 LazyOk,
159};
160
161static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope);155static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope);
162static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval,156static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval,
163 ResultLoc *result_loc);157 ResultLoc *result_loc);
...@@ -6836,7 +6830,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod...@@ -6836,7 +6830,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod
6836 const char modifier = *buf_ptr(asm_output->constraint);6830 const char modifier = *buf_ptr(asm_output->constraint);
6837 if (modifier != '=') {6831 if (modifier != '=') {
6838 add_node_error(irb->codegen, node,6832 add_node_error(irb->codegen, node,
6839 buf_sprintf("invalid modifier starting output constraint for '%s': '%c', only '=' is supported."6833 buf_sprintf("invalid modifier starting output constraint for '%s': '%c', only '=' is supported"
6840 " Compiler TODO: see https://github.com/ziglang/zig/issues/215",6834 " Compiler TODO: see https://github.com/ziglang/zig/issues/215",
6841 buf_ptr(asm_output->asm_symbolic_name), modifier));6835 buf_ptr(asm_output->asm_symbolic_name), modifier));
6842 return irb->codegen->invalid_instruction;6836 return irb->codegen->invalid_instruction;
...@@ -6860,7 +6854,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod...@@ -6860,7 +6854,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod
6860 uint32_t len = asm_token.end - asm_token.start - 2;6854 uint32_t len = asm_token.end - asm_token.start - 2;
68616855
6862 add_node_error(irb->codegen, node,6856 add_node_error(irb->codegen, node,
6863 buf_sprintf("could not find '%.*s' in the inputs or outputs.",6857 buf_sprintf("could not find '%.*s' in the inputs or outputs",
6864 len, ptr));6858 len, ptr));
6865 return irb->codegen->invalid_instruction;6859 return irb->codegen->invalid_instruction;
6866 }6860 }
...@@ -8114,6 +8108,9 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc...@@ -8114,6 +8108,9 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc
8114 }8108 }
8115 IrInstruction *result = ir_gen_node_raw(irb, node, scope, lval, result_loc);8109 IrInstruction *result = ir_gen_node_raw(irb, node, scope, lval, result_loc);
8116 if (result == irb->codegen->invalid_instruction) {8110 if (result == irb->codegen->invalid_instruction) {
8111 if (irb->exec->first_err_trace_msg == nullptr) {
8112 irb->exec->first_err_trace_msg = irb->codegen->trace_err;
8113 }
8117 src_assert(irb->exec->first_err_trace_msg != nullptr, node);8114 src_assert(irb->exec->first_err_trace_msg != nullptr, node);
8118 }8115 }
8119 return result;8116 return result;
src/tokenizer.cpp+1-1
...@@ -841,7 +841,7 @@ void tokenize(Buf *buf, Tokenization *out) {...@@ -841,7 +841,7 @@ void tokenize(Buf *buf, Tokenization *out) {
841 case TokenizeStateSawAmpersand:841 case TokenizeStateSawAmpersand:
842 switch (c) {842 switch (c) {
843 case '&':843 case '&':
844 tokenize_error(&t, "`&&` is invalid. Note that `and` is boolean AND.");844 tokenize_error(&t, "`&&` is invalid. Note that `and` is boolean AND");
845 break;845 break;
846 case '=':846 case '=':
847 set_token_id(&t, t.cur_tok, TokenIdBitAndEq);847 set_token_id(&t, t.cur_tok, TokenIdBitAndEq);
test/compile_errors.zig+6-6
...@@ -10,7 +10,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -10,7 +10,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10 \\ : [bar] "=r" (-> usize)10 \\ : [bar] "=r" (-> usize)
11 \\ );11 \\ );
12 \\}12 \\}
13 , "tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs.");13 , "tmp.zig:2:14: error: could not find 'foo' in the inputs or outputs");
14 tc.target = tests.Target{14 tc.target = tests.Target{
15 .Cross = tests.CrossTarget{15 .Cross = tests.CrossTarget{
16 .arch = .x86_64,16 .arch = .x86_64,
...@@ -53,8 +53,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -53,8 +53,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
53 \\}53 \\}
54 ,54 ,
55 "tmp.zig:8:1: error: '@Frame(rangeSum)' depends on itself",55 "tmp.zig:8:1: error: '@Frame(rangeSum)' depends on itself",
56 "tmp.zig:15:33: note: when analyzing type '@Frame(rangeSumIndirect)' here",56 "tmp.zig:15:33: note: when analyzing type '@Frame(rangeSum)' here",
57 "tmp.zig:26:25: note: when analyzing type '@Frame(rangeSum)' here",57 "tmp.zig:26:25: note: when analyzing type '@Frame(rangeSumIndirect)' here",
58 );58 );
5959
60 cases.add(60 cases.add(
...@@ -245,7 +245,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -245,7 +245,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
245 ,245 ,
246 "tmp.zig:4:1: error: unable to determine async function frame of 'amain'",246 "tmp.zig:4:1: error: unable to determine async function frame of 'amain'",
247 "tmp.zig:5:10: note: analysis of function 'other' depends on the frame",247 "tmp.zig:5:10: note: analysis of function 'other' depends on the frame",
248 "tmp.zig:8:13: note: depends on the frame here",248 "tmp.zig:8:13: note: referenced here",
249 );249 );
250250
251 cases.add(251 cases.add(
...@@ -258,7 +258,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -258,7 +258,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
258 \\}258 \\}
259 ,259 ,
260 "tmp.zig:4:1: error: cannot resolve '@Frame(amain)': function not fully analyzed yet",260 "tmp.zig:4:1: error: cannot resolve '@Frame(amain)': function not fully analyzed yet",
261 "tmp.zig:5:13: note: depends on its own frame here",261 "tmp.zig:5:13: note: referenced here",
262 );262 );
263263
264 cases.add(264 cases.add(
...@@ -1091,7 +1091,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1091,7 +1091,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1091 \\ return 5678;1091 \\ return 5678;
1092 \\}1092 \\}
1093 ,1093 ,
1094 "tmp.zig:2:12: error: `&&` is invalid. Note that `and` is boolean AND.",1094 "tmp.zig:2:12: error: `&&` is invalid. Note that `and` is boolean AND",
1095 );1095 );
10961096
1097 cases.add(1097 cases.add(