Commit d9eabde319
Changed files (6)
cmake/Findllvm.cmake
@@ -104,9 +104,11 @@ else()
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_SYSTEM_LIBS})
- if(LLVM_LIBRARY)
+ if(LLVM_LIBRARY AND NOT LLVM_LIBRARIES)
set(LLVM_LIBRARIES ${LLVM_LIBRARY})
endif()
+
+ link_directories("${CMAKE_PREFIX_PATH}/lib")
endif()
src/ir.cpp
@@ -11432,6 +11432,17 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
if (type_is_invalid(child_type)) {
return ira->codegen->builtin_types.entry_invalid;
} else if (is_container(child_type)) {
+ if (is_slice(child_type) && buf_eql_str(field_name, "Child")) {
+ bool ptr_is_const = true;
+ bool ptr_is_volatile = false;
+ TypeStructField *ptr_field = &child_type->data.structure.fields[slice_ptr_index];
+ assert(ptr_field->type_entry->id == TypeTableEntryIdPointer);
+ TypeTableEntry *child_type = ptr_field->type_entry->data.pointer.child_type;
+ return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
+ create_const_type(ira->codegen, child_type),
+ ira->codegen->builtin_types.entry_type,
+ ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile);
+ }
if (child_type->id == TypeTableEntryIdEnum) {
ensure_complete_type(ira->codegen, child_type);
if (child_type->data.enumeration.is_invalid)
@@ -11522,7 +11533,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
return ira->codegen->builtin_types.entry_invalid;
}
} else if (child_type->id == TypeTableEntryIdPointer) {
- if (buf_eql_str(field_name, "child")) {
+ if (buf_eql_str(field_name, "Child")) {
bool ptr_is_const = true;
bool ptr_is_volatile = false;
return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
@@ -11544,7 +11555,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
return ira->codegen->builtin_types.entry_invalid;
}
} else if (child_type->id == TypeTableEntryIdArray) {
- if (buf_eql_str(field_name, "child")) {
+ if (buf_eql_str(field_name, "Child")) {
bool ptr_is_const = true;
bool ptr_is_volatile = false;
return ir_analyze_const_ptr(ira, &field_ptr_instruction->base,
std/fmt/index.zig
@@ -208,7 +208,7 @@ pub fn formatValue(value: var, context: var, output: fn(@typeOf(context), []cons
return output(context, @errorName(value));
},
builtin.TypeId.Pointer => {
- if (@typeId(T.child) == builtin.TypeId.Array and T.child.child == u8) {
+ if (@typeId(T.Child) == builtin.TypeId.Array and T.Child.Child == u8) {
return output(context, (*value)[0..]);
} else {
@compileError("Unable to format type '" ++ @typeName(T) ++ "'");
test/cases/array.zig
@@ -89,7 +89,7 @@ test "array literal with specified size" {
test "array child property" {
var x: [5]i32 = undefined;
- assert(@typeOf(x).child == i32);
+ assert(@typeOf(x).Child == i32);
}
test "array len property" {
test/cases/misc.zig
@@ -536,7 +536,7 @@ export fn writeToVRam() {
}
test "pointer child field" {
- assert((&u32).child == u32);
+ assert((&u32).Child == u32);
}
const OpaqueA = @OpaqueType();
test/cases/slice.zig
@@ -9,3 +9,9 @@ test "compile time slice of pointer to hard coded address" {
assert(@ptrToInt(y.ptr) == 0x1100);
assert(y.len == 0x400);
}
+
+test "slice child property" {
+ var array: [5]i32 = undefined;
+ var slice = array[0..];
+ assert(@typeOf(slice).Child == i32);
+}