mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix for getting the correct generic type of consts. Fix of late initialization of structs using compound literals.
This commit is contained in:
@@ -275,6 +275,7 @@ LLVMValueRef llvm_emit_const_initializer(GenContext *c, ConstInitializer *const_
|
||||
LLVMTypeRef expected_type = llvm_get_type(c, const_init->init_struct[i]->type);
|
||||
LLVMValueRef element = llvm_emit_const_initializer(c, const_init->init_struct[i]);
|
||||
LLVMTypeRef element_type = LLVMTypeOf(element);
|
||||
assert(LLVMIsConstant(element));
|
||||
if (expected_type != element_type)
|
||||
{
|
||||
was_modified = true;
|
||||
|
||||
@@ -3068,11 +3068,13 @@ static bool sema_analyse_parameterized_define(SemaContext *c, Decl *decl)
|
||||
}
|
||||
}
|
||||
assert(symbol);
|
||||
if (!sema_analyse_decl(c, symbol)) return false;
|
||||
unit_register_external_symbol(c->compilation_unit, symbol);
|
||||
switch (decl->define_decl.define_kind)
|
||||
{
|
||||
case DEFINE_IDENT_GENERIC:
|
||||
decl->define_decl.alias = symbol;
|
||||
decl->type = symbol->type;
|
||||
return true;
|
||||
case DEFINE_TYPE_GENERIC:
|
||||
{
|
||||
@@ -3135,7 +3137,7 @@ static inline bool sema_analyse_define(SemaContext *c, Decl *decl)
|
||||
if (decl->define_decl.define_kind == DEFINE_IDENT_ALIAS)
|
||||
{
|
||||
Decl *symbol = sema_resolve_symbol(c, decl->define_decl.ident, decl->define_decl.path, decl->define_decl.span);
|
||||
if (!decl_ok(symbol)) return false;
|
||||
if (!sema_analyse_decl(c, symbol)) return false;
|
||||
decl->type = symbol->type;
|
||||
decl->define_decl.alias = symbol;
|
||||
return true;
|
||||
|
||||
@@ -776,10 +776,10 @@ static inline bool sema_expr_analyse_identifier(SemaContext *context, Type *to,
|
||||
}
|
||||
|
||||
Decl *decl = sema_find_path_symbol(context, expr->identifier_expr.ident, expr->identifier_expr.path);
|
||||
|
||||
// Is this a broken decl?
|
||||
if (!decl_ok(decl)) return false;
|
||||
|
||||
|
||||
// Rerun if we can't do inference.
|
||||
if (!decl)
|
||||
{
|
||||
@@ -7177,6 +7177,7 @@ static inline bool sema_expr_analyse_compound_literal(SemaContext *context, Expr
|
||||
{
|
||||
if (!sema_resolve_type_info(context, expr->expr_compound_literal.type_info)) return false;
|
||||
Type *type = expr->expr_compound_literal.type_info->type;
|
||||
if (!sema_resolve_type_decl(context, type)) return false;
|
||||
if (type_is_optional(type))
|
||||
{
|
||||
SEMA_ERROR(expr->expr_compound_literal.type_info,
|
||||
@@ -7652,7 +7653,7 @@ TokenType sema_splitpathref(const char *string, ArraySize len, Path **path_ref,
|
||||
if (!char_is_alphanum_(c)) return TOKEN_INVALID_TOKEN;
|
||||
hash = FNV1a(c, hash);
|
||||
}
|
||||
TokenType type;
|
||||
TokenType type = TOKEN_INVALID_TOKEN;
|
||||
*ident_ref = symtab_find(string, len, hash, &type);
|
||||
if (!*ident_ref) return TOKEN_IDENT;
|
||||
switch (type)
|
||||
|
||||
@@ -66,6 +66,7 @@ static inline void sema_not_enough_elements_error(Expr *initializer, int element
|
||||
*/
|
||||
static inline bool sema_expr_analyse_struct_plain_initializer(SemaContext *context, Decl *assigned, Expr *initializer)
|
||||
{
|
||||
assert(assigned->resolve_status == RESOLVE_DONE);
|
||||
Expr **elements = initializer->initializer_list;
|
||||
Decl **members = assigned->strukt.members;
|
||||
MemberIndex size = (MemberIndex)vec_size(elements);
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define COMPILER_VERSION "0.4.510"
|
||||
#define COMPILER_VERSION "0.4.511"
|
||||
Reference in New Issue
Block a user