@@ -1025,7 +1025,7 @@ static IrInstruction *ir_build_ptr_type_of(IrBuilder *irb, Scope *scope, AstNode
1025
1025
ptr_type_of_instruction->bit_offset_start = bit_offset_start;
1026
1026
ptr_type_of_instruction->bit_offset_end = bit_offset_end;
1027
1027
1028
- ir_ref_instruction(align_value, irb->current_basic_block);
1028
+ if (align_value) ir_ref_instruction(align_value, irb->current_basic_block);
1029
1029
ir_ref_instruction(child_type, irb->current_basic_block);
1030
1030
1031
1031
return &ptr_type_of_instruction->base;
@@ -4897,13 +4897,18 @@ static IrInstruction *ir_gen_address_of(IrBuilder *irb, Scope *scope, AstNode *n
4897
4897
AstNode *expr_node = node->data.addr_of_expr.op_expr;
4898
4898
AstNode *align_expr = node->data.addr_of_expr.align_expr;
4899
4899
4900
- if (align_expr == nullptr) {
4900
+ if (align_expr == nullptr && !is_const && !is_volatile ) {
4901
4901
return ir_gen_node_extra(irb, expr_node, scope, make_lval_addr(is_const, is_volatile));
4902
4902
}
4903
4903
4904
- IrInstruction *align_value = ir_gen_node(irb, align_expr, scope);
4905
- if (align_value == irb->codegen->invalid_instruction)
4906
- return align_value;
4904
+ IrInstruction *align_value;
4905
+ if (align_expr != nullptr) {
4906
+ align_value = ir_gen_node(irb, align_expr, scope);
4907
+ if (align_value == irb->codegen->invalid_instruction)
4908
+ return align_value;
4909
+ } else {
4910
+ align_value = nullptr;
4911
+ }
4907
4912
4908
4913
IrInstruction *child_type = ir_gen_node(irb, expr_node, scope);
4909
4914
if (child_type == irb->codegen->invalid_instruction)
@@ -15959,8 +15964,12 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type_of(IrAnalyze *ira, IrInst
15959
15964
return ira->codegen->builtin_types.entry_invalid;
15960
15965
15961
15966
uint32_t align_bytes;
15962
- if (!ir_resolve_align(ira, instruction->align_value->other, &align_bytes))
15963
- return ira->codegen->builtin_types.entry_invalid;
15967
+ if (instruction->align_value != nullptr) {
15968
+ if (!ir_resolve_align(ira, instruction->align_value->other, &align_bytes))
15969
+ return ira->codegen->builtin_types.entry_invalid;
15970
+ } else {
15971
+ align_bytes = get_abi_alignment(ira->codegen, child_type);
15972
+ }
15964
15973
15965
15974
ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
15966
15975
out_val->data.x_type = get_pointer_to_type_extra(ira->codegen, child_type,
0 commit comments