Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ast/qualtype.c2
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ public fn PointerType* QualType.getPointerTypeOrNil(const QualType qt) {
*/

public fn ArrayType* QualType.getArrayTypeOrNil(const QualType qt) {
const Type* t = qt.getTypeOrNil();
QualType canon = qt.getCanonicalType();
const Type* t = canon.getTypeOrNil();
if (t && t.isArrayType()) return (ArrayType*)t;
return nil;
}
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15795,7 +15795,7 @@ static ast_StructType* ast_QualType_getStructTypeOrNil(const ast_QualType qt)

static ast_ArrayType* ast_QualType_getArrayTypeOrNil(const ast_QualType qt)
{
const ast_Type* t = ast_QualType_getTypeOrNil(qt);
const ast_Type* t = ast_QualType_getTypeOrNil(ast_QualType_getCanonicalType(qt));
if (t && ast_Type_isArrayType(t)) return (ast_ArrayType*)t;
return NULL;
}
Expand Down Expand Up @@ -34109,9 +34109,9 @@ static void c_generator_Generator_emitAliasType(c_generator_Generator* gen, stri
qt = ast_QualType_getCanonicalType(qt);
string_buffer_Buf_add(out, "typedef ");
c_generator_Generator_emitTypePre(gen, out, qt, false);
c_generator_Generator_emitTypePost(gen, out, qt);
string_buffer_Buf_space(out);
c_generator_Generator_emitCName(gen, out, d);
c_generator_Generator_emitTypePost(gen, out, qt);
string_buffer_Buf_add(out, ";\n");
}

Expand Down
8 changes: 8 additions & 0 deletions test/builtins/elemsof_array_alias.c2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @warnings{no-unused}
module test;

type Array i32[20];
Array a;

static_assert(20, countof(Array));
static_assert(20, countof(a));
Loading