| ... | ... | @@ -9887,6 +9887,10 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira, |
| 9887 | 9887 | Tld *tld = instruction->tld; |
| 9888 | 9888 | IrInstruction *align_value = instruction->value->other; |
| 9889 | 9889 | |
| 9890 | resolve_top_level_decl(ira->codegen, tld, true); |
| 9891 | if (tld->resolution == TldResolutionInvalid) |
| 9892 | return ira->codegen->builtin_types.entry_invalid; |
| 9893 | |
| 9890 | 9894 | uint64_t scalar_align; |
| 9891 | 9895 | if (!ir_resolve_usize(ira, align_value, &scalar_align)) |
| 9892 | 9896 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -9902,11 +9906,25 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira, |
| 9902 | 9906 | TldVar *tld_var = (TldVar *)tld; |
| 9903 | 9907 | set_global_align_node = &tld_var->set_global_align_node; |
| 9904 | 9908 | alignment_ptr = &tld_var->alignment; |
| 9909 | |
| 9910 | if (tld_var->var->linkage == VarLinkageExternal) { |
| 9911 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, |
| 9912 | buf_sprintf("cannot set alignment of external variable '%s'", buf_ptr(&tld_var->var->name))); |
| 9913 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); |
| 9914 | return ira->codegen->builtin_types.entry_invalid; |
| 9915 | } |
| 9905 | 9916 | } else if (tld->id == TldIdFn) { |
| 9906 | 9917 | TldFn *tld_fn = (TldFn *)tld; |
| 9907 | 9918 | FnTableEntry *fn_entry = tld_fn->fn_entry; |
| 9908 | 9919 | set_global_align_node = &fn_entry->set_global_align_node; |
| 9909 | 9920 | alignment_ptr = &fn_entry->alignment; |
| 9921 | |
| 9922 | if (fn_entry->def_scope == nullptr) { |
| 9923 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, |
| 9924 | buf_sprintf("cannot set alignment of external function '%s'", buf_ptr(&fn_entry->symbol_name))); |
| 9925 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); |
| 9926 | return ira->codegen->builtin_types.entry_invalid; |
| 9927 | } |
| 9910 | 9928 | } else { |
| 9911 | 9929 | // error is caught in pass1 IR gen |
| 9912 | 9930 | zig_unreachable(); |
| ... | ... | @@ -9932,6 +9950,10 @@ static TypeTableEntry *ir_analyze_instruction_set_global_section(IrAnalyze *ira, |
| 9932 | 9950 | Tld *tld = instruction->tld; |
| 9933 | 9951 | IrInstruction *section_value = instruction->value->other; |
| 9934 | 9952 | |
| 9953 | resolve_top_level_decl(ira->codegen, tld, true); |
| 9954 | if (tld->resolution == TldResolutionInvalid) |
| 9955 | return ira->codegen->builtin_types.entry_invalid; |
| 9956 | |
| 9935 | 9957 | Buf *section_name = ir_resolve_str(ira, section_value); |
| 9936 | 9958 | if (!section_name) |
| 9937 | 9959 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -9942,11 +9964,25 @@ static TypeTableEntry *ir_analyze_instruction_set_global_section(IrAnalyze *ira, |
| 9942 | 9964 | TldVar *tld_var = (TldVar *)tld; |
| 9943 | 9965 | set_global_section_node = &tld_var->set_global_section_node; |
| 9944 | 9966 | section_name_ptr = &tld_var->section_name; |
| 9967 | |
| 9968 | if (tld_var->var->linkage == VarLinkageExternal) { |
| 9969 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, |
| 9970 | buf_sprintf("cannot set section of external variable '%s'", buf_ptr(&tld_var->var->name))); |
| 9971 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); |
| 9972 | return ira->codegen->builtin_types.entry_invalid; |
| 9973 | } |
| 9945 | 9974 | } else if (tld->id == TldIdFn) { |
| 9946 | 9975 | TldFn *tld_fn = (TldFn *)tld; |
| 9947 | 9976 | FnTableEntry *fn_entry = tld_fn->fn_entry; |
| 9948 | 9977 | set_global_section_node = &fn_entry->set_global_section_node; |
| 9949 | 9978 | section_name_ptr = &fn_entry->section_name; |
| 9979 | |
| 9980 | if (fn_entry->def_scope == nullptr) { |
| 9981 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, |
| 9982 | buf_sprintf("cannot set section of external function '%s'", buf_ptr(&fn_entry->symbol_name))); |
| 9983 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); |
| 9984 | return ira->codegen->builtin_types.entry_invalid; |
| 9985 | } |
| 9950 | 9986 | } else { |
| 9951 | 9987 | // error is caught in pass1 IR gen |
| 9952 | 9988 | zig_unreachable(); |