Fix compile with gcc 14.2.1 (#1594)

* 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 <christoffer@aegik.com>
This commit is contained in:
Waqar Ahmed
2024-11-04 04:20:14 +05:00
committed by GitHub
parent ba34b45651
commit 213831289a
4 changed files with 8 additions and 5 deletions

View File

@@ -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;

View File

@@ -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)

View File

@@ -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++)
@@ -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)

View File

@@ -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:
@@ -1318,3 +1318,4 @@ static Decl *sema_resolve_element_for_name(SemaContext *context, Decl **decls, D
(*index)++;
return found;
}