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 {
5353 PtrLenC,
5454};
5555
56enum UndefAllowed {
57 UndefOk,
58 UndefBad,
59 LazyOkNoUndef,
60 LazyOk,
61};
62
5663enum X64CABIClass {
5764 X64CABIClass_Unknown,
5865 X64CABIClass_MEMORY,
src/analyze.cpp+18-11
......@@ -59,6 +59,7 @@ ErrorMsg *add_token_error(CodeGen *g, ZigType *owner, Token *token, Buf *msg) {
5959 root_struct->source_code, root_struct->line_offsets, msg);
6060
6161 g->errors.append(err);
62 g->trace_err = err;
6263 return err;
6364}
6465
......@@ -1793,7 +1794,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
17931794 if (struct_type->data.structure.resolve_loop_flag_other) {
17941795 if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) {
17951796 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
1796 g->trace_err = add_node_error(g, decl_node,
1797 add_node_error(g, decl_node,
17971798 buf_sprintf("struct '%s' depends on its own size", buf_ptr(&struct_type->name)));
17981799 }
17991800 return ErrorSemanticAnalyzeFail;
......@@ -1947,7 +1948,7 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) {
19471948 if (union_type->data.unionation.resolve_loop_flag_other) {
19481949 if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) {
19491950 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
1950 g->trace_err = add_node_error(g, decl_node,
1951 add_node_error(g, decl_node,
19511952 buf_sprintf("union '%s' depends on its own alignment", buf_ptr(&union_type->name)));
19521953 }
19531954 return ErrorSemanticAnalyzeFail;
......@@ -2058,7 +2059,7 @@ static Error resolve_union_type(CodeGen *g, ZigType *union_type) {
20582059 if (union_type->data.unionation.resolve_loop_flag_other) {
20592060 if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) {
20602061 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
2061 g->trace_err = add_node_error(g, decl_node,
2062 add_node_error(g, decl_node,
20622063 buf_sprintf("union '%s' depends on its own size", buf_ptr(&union_type->name)));
20632064 }
20642065 return ErrorSemanticAnalyzeFail;
......@@ -2160,7 +2161,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) {
21602161 if (enum_type->data.enumeration.resolve_loop_flag) {
21612162 if (enum_type->data.enumeration.resolve_status != ResolveStatusInvalid) {
21622163 enum_type->data.enumeration.resolve_status = ResolveStatusInvalid;
2163 g->trace_err = add_node_error(g, decl_node,
2164 add_node_error(g, decl_node,
21642165 buf_sprintf("enum '%s' depends on itself",
21652166 buf_ptr(&enum_type->name)));
21662167 }
......@@ -2337,7 +2338,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) {
23372338 if (struct_type->data.structure.resolve_loop_flag_zero_bits) {
23382339 if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) {
23392340 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2340 g->trace_err = add_node_error(g, decl_node,
2341 add_node_error(g, decl_node,
23412342 buf_sprintf("struct '%s' depends on itself",
23422343 buf_ptr(&struct_type->name)));
23432344 }
......@@ -2462,7 +2463,7 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) {
24622463 if (struct_type->data.structure.resolve_loop_flag_other) {
24632464 if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) {
24642465 struct_type->data.structure.resolve_status = ResolveStatusInvalid;
2465 g->trace_err = add_node_error(g, decl_node,
2466 add_node_error(g, decl_node,
24662467 buf_sprintf("struct '%s' depends on its own alignment", buf_ptr(&struct_type->name)));
24672468 }
24682469 return ErrorSemanticAnalyzeFail;
......@@ -2530,7 +2531,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
25302531 if (union_type->data.unionation.resolve_loop_flag_zero_bits) {
25312532 if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) {
25322533 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
2533 g->trace_err = add_node_error(g, decl_node,
2534 add_node_error(g, decl_node,
25342535 buf_sprintf("union '%s' depends on itself",
25352536 buf_ptr(&union_type->name)));
25362537 }
......@@ -3423,7 +3424,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) {
34233424 ZigType *explicit_type = nullptr;
34243425 if (var_decl->type) {
34253426 if (tld_var->analyzing_type) {
3426 g->trace_err = add_node_error(g, var_decl->type,
3427 add_node_error(g, var_decl->type,
34273428 buf_sprintf("type of '%s' depends on itself", buf_ptr(tld_var->base.name)));
34283429 explicit_type = g->builtin_types.entry_invalid;
34293430 } else {
......@@ -4001,6 +4002,13 @@ static void resolve_async_fn_frame(CodeGen *g, ZigFn *fn) {
40014002 ZigType *frame_type = get_fn_frame_type(g, fn);
40024003 Error err;
40034004 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 }
40044012 fn->anal_state = FnAnalStateInvalid;
40054013 return;
40064014 }
......@@ -5406,8 +5414,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
54065414
54075415 if (frame_type->data.frame.resolve_loop_type != nullptr) {
54085416 if (!frame_type->data.frame.reported_loop_err) {
5409 frame_type->data.frame.reported_loop_err = true;
5410 g->trace_err = add_node_error(g, fn->proto_node,
5417 add_node_error(g, fn->proto_node,
54115418 buf_sprintf("'%s' depends on itself", buf_ptr(&frame_type->name)));
54125419 }
54135420 return ErrorSemanticAnalyzeFail;
......@@ -5424,7 +5431,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
54245431 return ErrorSemanticAnalyzeFail;
54255432 break;
54265433 case FnAnalStateProbing: {
5427 g->trace_err = add_node_error(g, fn->proto_node,
5434 add_node_error(g, fn->proto_node,
54285435 buf_sprintf("cannot resolve '%s': function not fully analyzed yet",
54295436 buf_ptr(&frame_type->name)));
54305437 return ErrorSemanticAnalyzeFail;
src/ir.cpp+5-8
......@@ -152,12 +152,6 @@ struct ConstCastBadAllowsZero {
152152};
153153
154154
155enum UndefAllowed {
156 UndefOk,
157 UndefBad,
158 LazyOk,
159};
160
161155static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope);
162156static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval,
163157 ResultLoc *result_loc);
......@@ -6836,7 +6830,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod
68366830 const char modifier = *buf_ptr(asm_output->constraint);
68376831 if (modifier != '=') {
68386832 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"
68406834 " Compiler TODO: see https://github.com/ziglang/zig/issues/215",
68416835 buf_ptr(asm_output->asm_symbolic_name), modifier));
68426836 return irb->codegen->invalid_instruction;
......@@ -6860,7 +6854,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod
68606854 uint32_t len = asm_token.end - asm_token.start - 2;
68616855
68626856 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",
68646858 len, ptr));
68656859 return irb->codegen->invalid_instruction;
68666860 }
......@@ -8114,6 +8108,9 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc
81148108 }
81158109 IrInstruction *result = ir_gen_node_raw(irb, node, scope, lval, result_loc);
81168110 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 }
81178114 src_assert(irb->exec->first_err_trace_msg != nullptr, node);
81188115 }
81198116 return result;
src/tokenizer.cpp+1-1
......@@ -841,7 +841,7 @@ void tokenize(Buf *buf, Tokenization *out) {
841841 case TokenizeStateSawAmpersand:
842842 switch (c) {
843843 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");
845845 break;
846846 case '=':
847847 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 {
1010 \\ : [bar] "=r" (-> usize)
1111 \\ );
1212 \\}
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");
1414 tc.target = tests.Target{
1515 .Cross = tests.CrossTarget{
1616 .arch = .x86_64,
......@@ -53,8 +53,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
5353 \\}
5454 ,
5555 "tmp.zig:8:1: error: '@Frame(rangeSum)' depends on itself",
56 "tmp.zig:15:33: note: when analyzing type '@Frame(rangeSumIndirect)' here",
57 "tmp.zig:26:25: note: when analyzing type '@Frame(rangeSum)' here",
56 "tmp.zig:15:33: note: when analyzing type '@Frame(rangeSum)' here",
57 "tmp.zig:26:25: note: when analyzing type '@Frame(rangeSumIndirect)' here",
5858 );
5959
6060 cases.add(
......@@ -245,7 +245,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
245245 ,
246246 "tmp.zig:4:1: error: unable to determine async function frame of 'amain'",
247247 "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",
249249 );
250250
251251 cases.add(
......@@ -258,7 +258,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
258258 \\}
259259 ,
260260 "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",
262262 );
263263
264264 cases.add(
......@@ -1091,7 +1091,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10911091 \\ return 5678;
10921092 \\}
10931093 ,
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",
10951095 );
10961096
10971097 cases.add(