Skip to content

Commit

Permalink
Fix compile with gcc 14.2.1 (#1594)
Browse files Browse the repository at this point in the history
* Fix compile with gcc 14.2.1 Fixes -Werror=maybe-uninitialized warnings
* Updated to use INVALID_PTR rather than NULL.
---------

Co-authored-by: Christoffer Lerno <[email protected]>
  • Loading branch information
Waqar144 and lerno authored Nov 3, 2024
1 parent ba34b45 commit 2138312
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/compiler/compiler_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ typedef uint16_t FileId;
#define EXPAND_EXPR_STRING(str_) (str_)->const_expr.bytes.len, (str_)->const_expr.bytes.ptr
#define TABLE_MAX_LOAD 0.5

#define INVALID_PTR ((void*)(uintptr_t)0xAAAAAAAAAAAAAAAA)

typedef struct Ast_ Ast;
typedef struct Decl_ Decl;
typedef struct TypeInfo_ TypeInfo;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/llvm_codegen_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2967,7 +2967,7 @@ static void llvm_emit_slice_values(GenContext *c, Expr *slice, BEValue *parent_r

// Emit the start and end

Type *start_type;
Type *start_type = (Type*)INVALID_PTR;
Range range = slice->slice_expr.range;
BEValue start_index;
switch (range.range_type)
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/sema_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ INLINE bool sema_call_evaluate_arguments(SemaContext *context, CalledDecl *calle
bool has_named = false;
bool found_splat = false;
ArrayIndex last_index = -1;
Expr *last_named_arg;
Expr *last_named_arg = INVALID_PTR;
Expr *last = NULL;
int needed = func_param_count - (callee->struct_var ? 1 : 0);
for (unsigned i = 0; i < num_args; i++)
Expand Down Expand Up @@ -4280,7 +4280,7 @@ static bool sema_expr_rewrite_to_typeid_property(SemaContext *context, Expr *exp
static inline bool sema_expr_fold_to_index(Expr *expr, Expr *parent, SubscriptIndex index_expr)
{
ConstInitializer *init = parent->const_expr.initializer;
ConstInitializer *result;
ConstInitializer *result = INVALID_PTR;
ASSERT_SPAN(expr, !index_expr.start_from_end);
ArrayIndex index = exprptr(index_expr.expr)->const_expr.ixx.i.low;
switch (init->kind)
Expand Down
5 changes: 3 additions & 2 deletions src/compiler/sema_initializers.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ static inline void sema_update_const_initializer_with_designator(

bool const_init_local_init_may_be_global_inner(ConstInitializer *init, bool top)
{
ConstInitializer **list;
unsigned len;
ConstInitializer **list = INVALID_PTR;
unsigned len = (unsigned)-1;
switch (init->kind)
{
case CONST_INIT_ZERO:
Expand Down Expand Up @@ -1318,3 +1318,4 @@ static Decl *sema_resolve_element_for_name(SemaContext *context, Decl **decls, D
(*index)++;
return found;
}

0 comments on commit 2138312

Please sign in to comment.