| author | |
| committer | |
| log | 6356724057ffc94fec03c697ae99bed32d33d2f7 |
| tree | a8aa0b8c108fce3bdfeffd5f5322d661798c74bc |
| parent | 57cd074959cd529f0648264e877f9819f0209ddf |
| parent | 03732860bee5c123f24781928e7aa01fce05d5ea |
3 files changed, 21 insertions(+), 5 deletions(-)
src/link.cpp+7-2| ... | ... | @@ -485,8 +485,13 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 485 | 485 | continue; |
| 486 | 486 | } |
| 487 | 487 | if (link_lib->provided_explicitly) { |
| 488 | Buf *arg = buf_sprintf("-l%s", buf_ptr(link_lib->name)); | |
| 489 | lj->args.append(buf_ptr(arg)); | |
| 488 | if (lj->codegen->zig_target.env_type == ZigLLVM_GNU) { | |
| 489 | Buf *arg = buf_sprintf("-l%s", buf_ptr(link_lib->name)); | |
| 490 | lj->args.append(buf_ptr(arg)); | |
| 491 | } | |
| 492 | else { | |
| 493 | lj->args.append(buf_ptr(link_lib->name)); | |
| 494 | } | |
| 490 | 495 | } else { |
| 491 | 496 | buf_resize(def_contents, 0); |
| 492 | 497 | buf_appendf(def_contents, "LIBRARY %s\nEXPORTS\n", buf_ptr(link_lib->name)); |
src/parsec.cpp+3-3| ... | ... | @@ -2577,11 +2577,10 @@ static AstNode *resolve_typdef_as_builtin(Context *c, const TypedefNameDecl *typ |
| 2577 | 2577 | } |
| 2578 | 2578 | |
| 2579 | 2579 | static AstNode *resolve_typedef_decl(Context *c, const TypedefNameDecl *typedef_decl) { |
| 2580 | auto existing_entry = c->decl_table.maybe_get((void*)typedef_decl); | |
| 2580 | auto existing_entry = c->decl_table.maybe_get((void*)typedef_decl->getCanonicalDecl()); | |
| 2581 | 2581 | if (existing_entry) { |
| 2582 | 2582 | return existing_entry->value; |
| 2583 | 2583 | } |
| 2584 | ||
| 2585 | 2584 | QualType child_qt = typedef_decl->getUnderlyingType(); |
| 2586 | 2585 | Buf *type_name = buf_create_from_str(decl_name(typedef_decl)); |
| 2587 | 2586 | |
| ... | ... | @@ -2624,7 +2623,7 @@ static AstNode *resolve_typedef_decl(Context *c, const TypedefNameDecl *typedef_ |
| 2624 | 2623 | add_global_var(c, type_name, type_node); |
| 2625 | 2624 | |
| 2626 | 2625 | AstNode *symbol_node = trans_create_node_symbol(c, type_name); |
| 2627 | c->decl_table.put(typedef_decl, symbol_node); | |
| 2626 | c->decl_table.put(typedef_decl->getCanonicalDecl(), symbol_node); | |
| 2628 | 2627 | return symbol_node; |
| 2629 | 2628 | } |
| 2630 | 2629 | |
| ... | ... | @@ -2750,6 +2749,7 @@ static AstNode *resolve_enum_decl(Context *c, const EnumDecl *enum_decl) { |
| 2750 | 2749 | AstNode *symbol_node = trans_create_node_symbol(c, full_type_name); |
| 2751 | 2750 | add_global_weak_alias(c, bare_name, full_type_name); |
| 2752 | 2751 | add_global_var(c, full_type_name, enum_node); |
| 2752 | c->decl_table.put(enum_decl->getCanonicalDecl(), symbol_node); | |
| 2753 | 2753 | return symbol_node; |
| 2754 | 2754 | } |
| 2755 | 2755 | } |
test/parsec.zig+11| ... | ... | @@ -619,6 +619,17 @@ pub fn addCases(cases: &tests.ParseCContext) { |
| 619 | 619 | \\ }; |
| 620 | 620 | \\} |
| 621 | 621 | ); |
| 622 | ||
| 623 | cases.addC("duplicate typedef", | |
| 624 | \\typedef long foo; | |
| 625 | \\typedef int bar; | |
| 626 | \\typedef long foo; | |
| 627 | \\typedef int baz; | |
| 628 | , | |
| 629 | \\pub const foo = c_long; | |
| 630 | \\pub const bar = c_int; | |
| 631 | \\pub const baz = c_int; | |
| 632 | ); | |
| 622 | 633 | } |
| 623 | 634 | |
| 624 | 635 |