mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
Removal of #pragma mark, explicit conversions.
This commit is contained in:
@@ -157,7 +157,7 @@ add_executable(c3c
|
||||
if(NOT CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||
message(STATUS "using gcc/clang warning switches")
|
||||
target_compile_options(c3c PRIVATE -Wall -Werror -Wno-unknown-pragmas -Wno-unused-result
|
||||
-Wno-unused-function -Wno-unused-variable -Wno-unused-parameter)
|
||||
-Wimplicit-int-conversion -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter)
|
||||
endif()
|
||||
|
||||
target_include_directories(c3c PRIVATE
|
||||
|
||||
@@ -238,10 +238,10 @@ typedef struct Path_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char bitsize;
|
||||
unsigned char bytesize;
|
||||
unsigned char abi_alignment;
|
||||
unsigned char pref_alignment;
|
||||
unsigned bitsize : 8;
|
||||
unsigned bytesize : 8;
|
||||
unsigned abi_alignment : 8;
|
||||
unsigned pref_alignment : 8;
|
||||
} TypeBuiltin;
|
||||
|
||||
typedef struct
|
||||
@@ -1505,7 +1505,7 @@ typedef struct ABIArgInfo_
|
||||
struct
|
||||
{
|
||||
AbiType *type;
|
||||
uint8_t elements : 3;
|
||||
uint8_t elements : 7;
|
||||
bool prevent_flatten : 1;
|
||||
} direct_coerce;
|
||||
struct
|
||||
@@ -1771,7 +1771,7 @@ bool context_add_import(Context *context, Path *path, Token symbol, Token alias,
|
||||
bool context_set_module_from_filename(Context *context);
|
||||
bool context_set_module(Context *context, Path *path, TokenId *generic_parameters, bool is_private);
|
||||
|
||||
#pragma mark --- Decl functions
|
||||
// --- Decl functions
|
||||
|
||||
Decl *decl_new(DeclKind decl_kind, TokenId name, Visibility visibility);
|
||||
Decl *decl_new_with_type(TokenId name, DeclKind decl_type, Visibility visibility);
|
||||
@@ -1823,7 +1823,7 @@ static inline Decl *decl_flatten(Decl *decl)
|
||||
return decl;
|
||||
}
|
||||
|
||||
#pragma mark --- Diag functions
|
||||
// --- Diag functions
|
||||
|
||||
|
||||
void diag_verror_range(SourceLocation *location, const char *message, va_list args);
|
||||
@@ -1870,7 +1870,7 @@ static inline bool expr_is_init_list(Expr *expr)
|
||||
bool float_const_fits_type(const ExprConst *expr_const, TypeKind kind);
|
||||
|
||||
|
||||
#pragma mark --- Lexer functions
|
||||
// --- Lexer functions
|
||||
|
||||
|
||||
Token lexer_advance(Lexer *lexer);
|
||||
@@ -2164,7 +2164,7 @@ static inline bool type_is_pointer(Type *type)
|
||||
return kind == TYPE_POINTER;
|
||||
}
|
||||
|
||||
static inline uint64_t aligned_offset(uint64_t offset, uint64_t alignment)
|
||||
static inline ByteSize aligned_offset(uint64_t offset, uint64_t alignment)
|
||||
{
|
||||
return ((offset + alignment - 1) / alignment) * alignment;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ static inline void add_generic_token(Lexer *lexer, TokenType type)
|
||||
SourceLocation *location = sourceloc_alloc();
|
||||
unsigned char *token_type = (unsigned char *)toktype_alloc();
|
||||
TokenData *data = tokdata_alloc();
|
||||
*token_type = type;
|
||||
*token_type = (unsigned char)type;
|
||||
|
||||
// Set the location.
|
||||
location->file = lexer->current_file;
|
||||
@@ -743,7 +743,7 @@ static inline bool scan_char(Lexer *lexer)
|
||||
return add_error_token(lexer, "Expected a two character hex value after \\x.");
|
||||
}
|
||||
// We can now reassign c and use the default code.
|
||||
c = hex;
|
||||
c = (char)hex;
|
||||
break;
|
||||
}
|
||||
case 'u':
|
||||
|
||||
@@ -153,7 +153,8 @@ ABIArgInfo *abi_arg_new_expand_coerce(AbiType *target_type, unsigned offset)
|
||||
{
|
||||
ABIArgInfo *arg = abi_arg_new(ABI_ARG_EXPAND_COERCE);
|
||||
arg->coerce_expand.packed = offset > 0;
|
||||
arg->coerce_expand.offset_lo = offset;
|
||||
assert(offset <= 0xFF);
|
||||
arg->coerce_expand.offset_lo = (unsigned char)offset;
|
||||
arg->coerce_expand.lo_index = offset > 0 ? 1 : 0;
|
||||
arg->coerce_expand.lo = target_type;
|
||||
return arg;
|
||||
@@ -163,12 +164,13 @@ ABIArgInfo *abi_arg_new_expand_coerce_pair(AbiType *first_element, unsigned init
|
||||
{
|
||||
ABIArgInfo *arg = abi_arg_new(ABI_ARG_EXPAND_COERCE);
|
||||
arg->coerce_expand.packed = is_packed;
|
||||
arg->coerce_expand.offset_lo = initial_offset;
|
||||
assert(initial_offset <= 0xFF && padding <= 0xFF);
|
||||
arg->coerce_expand.offset_lo = (unsigned char)initial_offset;
|
||||
arg->coerce_expand.lo_index = initial_offset > 0 ? 1 : 0;
|
||||
arg->coerce_expand.lo = first_element;
|
||||
arg->coerce_expand.hi = second_element;
|
||||
arg->coerce_expand.padding_hi = padding;
|
||||
arg->coerce_expand.offset_hi = padding + initial_offset + abi_type_size(first_element);
|
||||
arg->coerce_expand.padding_hi = (uint8_t)padding;
|
||||
arg->coerce_expand.offset_hi = (uint8_t)(padding + initial_offset + abi_type_size(first_element));
|
||||
arg->coerce_expand.hi_index = arg->coerce_expand.lo_index + (padding > 0 ? 1U : 0U);
|
||||
return arg;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ ABIArgInfo *aarch64_classify_argument_type(Type *type)
|
||||
if (type_is_homogenous_aggregate(type, &base, &members))
|
||||
{
|
||||
ABIArgInfo *info = abi_arg_new_direct_coerce(abi_type_new_plain(base));
|
||||
info->direct_coerce.elements = members;
|
||||
assert(members < 128);
|
||||
info->direct_coerce.elements = (uint8_t)members;
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -72,7 +73,8 @@ ABIArgInfo *aarch64_classify_argument_type(Type *type)
|
||||
// We use a pair of i64 for 16-byte aggregate with 8-byte alignment.
|
||||
// For aggregates with 16-byte alignment, we use i128.
|
||||
ABIArgInfo *info = abi_arg_new_direct_coerce(abi_type_new_int_bits(alignment * 8));
|
||||
info->direct_coerce.elements = size / alignment;
|
||||
assert(size / alignment < 128);
|
||||
info->direct_coerce.elements = (uint8_t)(size / alignment);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ static bool riscv_detect_fpcc_struct_internal(Type *type, unsigned current_offse
|
||||
bool is_int = type_is_integer(type);
|
||||
bool is_float = type_is_float(type);
|
||||
unsigned flen = platform_target.riscv.flen;
|
||||
unsigned size = type_size(type);
|
||||
ByteSize size = type_size(type);
|
||||
if (is_int || is_float)
|
||||
{
|
||||
if (is_int && size > platform_target.riscv.xlen) return false;
|
||||
@@ -67,7 +67,7 @@ static bool riscv_detect_fpcc_struct_internal(Type *type, unsigned current_offse
|
||||
{
|
||||
ByteSize array_len = type->array.len;
|
||||
Type *element_type = type->array.base;
|
||||
unsigned element_size = type_size(element_type);
|
||||
ByteSize element_size = type_size(element_type);
|
||||
for (ByteSize i = 0; i < array_len; i++)
|
||||
{
|
||||
if (!riscv_detect_fpcc_struct_internal(element_type,
|
||||
@@ -76,7 +76,7 @@ static bool riscv_detect_fpcc_struct_internal(Type *type, unsigned current_offse
|
||||
field1_offset,
|
||||
field2,
|
||||
field2_offset)) return false;
|
||||
current_offset += element_size;
|
||||
current_offset += (unsigned)element_size;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ static bool riscv_detect_fpcc_struct_internal(Type *type, unsigned current_offse
|
||||
{
|
||||
Decl *member = members[i];
|
||||
if (!riscv_detect_fpcc_struct_internal(member->type,
|
||||
current_offset + member->offset,
|
||||
(unsigned)(current_offset + member->offset),
|
||||
field1,
|
||||
field1_offset,
|
||||
field2,
|
||||
|
||||
@@ -503,7 +503,8 @@ static inline ABIArgInfo *x86_classify_aggregate(CallABI call, Regs *regs, Type
|
||||
// but we do not generate this struct immediately here.
|
||||
unsigned size_in_regs = (size + 3) / 4;
|
||||
ABIArgInfo *info = abi_arg_new_direct_coerce(abi_type_new_int_bits(32));
|
||||
info->direct_coerce.elements = size_in_regs;
|
||||
assert(size_in_regs < 8);
|
||||
info->direct_coerce.elements = (uint8_t)size_in_regs;
|
||||
// Not in reg on MCU
|
||||
if (!platform_target.x86.is_mcu_api) info->attributes.by_reg = true;
|
||||
return info;
|
||||
|
||||
@@ -1166,7 +1166,7 @@ static void parse_hex(char **result_pointer, const char *data, const char *end)
|
||||
while ((val = char_to_nibble(*(data++))) < 0) if (data == end) goto DONE;
|
||||
while ((val2 = char_to_nibble(*(data++))) < 0);
|
||||
|
||||
*(data_current++) = (val << 4) | val2;
|
||||
*(data_current++) = (char)((val << 4) | val2);
|
||||
}
|
||||
DONE:
|
||||
*result_pointer = data_current;
|
||||
|
||||
@@ -185,7 +185,7 @@ static bool sema_analyse_union_members(Context *context, Decl *decl, Decl **memb
|
||||
// padding.
|
||||
if (size > rep_size)
|
||||
{
|
||||
decl->strukt.padding = size - rep_size;
|
||||
decl->strukt.padding = (int16_t)(size - rep_size);
|
||||
}
|
||||
|
||||
decl->strukt.size = size;
|
||||
@@ -291,7 +291,7 @@ static bool sema_analyse_struct_members(Context *context, Decl *decl, Decl **mem
|
||||
// in this case we need an additional padding
|
||||
if (size > aligned_offset(offset, natural_alignment))
|
||||
{
|
||||
decl->strukt.padding = size - offset;
|
||||
decl->strukt.padding = (int16_t)(size - offset);
|
||||
}
|
||||
|
||||
// If the size is smaller the naturally aligned struct, then it is also unaligned
|
||||
@@ -302,7 +302,7 @@ static bool sema_analyse_struct_members(Context *context, Decl *decl, Decl **mem
|
||||
if (is_unaligned && size > offset)
|
||||
{
|
||||
assert(!decl->strukt.padding);
|
||||
decl->strukt.padding = size - offset;
|
||||
decl->strukt.padding = (int16_t)(size - offset);
|
||||
}
|
||||
decl->is_packed = is_unaligned;
|
||||
decl->strukt.size = size;
|
||||
|
||||
@@ -30,7 +30,7 @@ void file_find_top_dir();
|
||||
void file_add_wildcard_files(const char ***files, const char *path, bool recursive);
|
||||
void *cmalloc(size_t size);
|
||||
void memory_init(void);
|
||||
void *malloc_arena(unsigned long mem);
|
||||
void *malloc_arena(size_t mem);
|
||||
void free_arena(void);
|
||||
void print_arena_status(void);
|
||||
void run_arena_allocator_tests(void);
|
||||
@@ -358,9 +358,10 @@ typedef struct
|
||||
|
||||
static inline VHeader_* vec_new_(size_t element_size, size_t capacity)
|
||||
{
|
||||
assert(capacity < UINT32_MAX);
|
||||
VHeader_ *header = malloc_arena(element_size * capacity + sizeof(VHeader_));
|
||||
header->size = 0;
|
||||
header->capacity = capacity;
|
||||
header->capacity = (unsigned)capacity;
|
||||
return header;
|
||||
}
|
||||
|
||||
|
||||
@@ -956,61 +956,61 @@ void toml_encode_unicode_scalar(TomlString *result, TomlParser *parser, int n, T
|
||||
|
||||
if (scalar <= 0x7ff)
|
||||
{
|
||||
toml_string_append_char(result, 0xc0 | (scalar >> 6), &err);
|
||||
toml_string_append_char(result, (char)(0xc0 | (scalar >> 6)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | (scalar & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | (scalar & 0x3f)), &err);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (scalar <= 0xffff)
|
||||
{
|
||||
toml_string_append_char(result, 0xe0 | (scalar >> 12), &err);
|
||||
toml_string_append_char(result, (char)(0xe0 | (scalar >> 12)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | ((scalar >> 6) & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | ((scalar >> 6) & 0x3f)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | (scalar & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | (scalar & 0x3f)), &err);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (scalar <= 0x1fffff)
|
||||
{
|
||||
toml_string_append_char(result, 0xf0 | (scalar >> 18), &err);
|
||||
toml_string_append_char(result, (char)(0xf0 | (scalar >> 18)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | ((scalar >> 12) & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | ((scalar >> 12) & 0x3f)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | ((scalar >> 6) & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | ((scalar >> 6) & 0x3f)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | (scalar & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | (scalar & 0x3f)), &err);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (scalar <= 0x3ffffff)
|
||||
{
|
||||
toml_string_append_char(result, 0xf8 | (scalar >> 24), &err);
|
||||
toml_string_append_char(result, (char)(0xf8 | (scalar >> 24)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | ((scalar >> 18) & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | ((scalar >> 18) & 0x3f)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | ((scalar >> 12) & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | ((scalar >> 12) & 0x3f)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | ((scalar >> 6) & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | ((scalar >> 6) & 0x3f)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | (scalar & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | (scalar & 0x3f)), &err);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (scalar <= 0x7fffffff)
|
||||
{
|
||||
toml_string_append_char(result, 0xfc | (scalar >> 30), &err);
|
||||
toml_string_append_char(result, (char)(0xfc | (scalar >> 30)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | ((scalar >> 24) & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | ((scalar >> 24) & 0x3f)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | ((scalar >> 18) & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | ((scalar >> 18) & 0x3f)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | ((scalar >> 12) & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | ((scalar >> 12) & 0x3f)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | ((scalar >> 6) & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | ((scalar >> 6) & 0x3f)), &err);
|
||||
if (err.code != TOML_OK) goto cleanup;
|
||||
toml_string_append_char(result, 0x80 | (scalar & 0x3f), &err);
|
||||
toml_string_append_char(result, (char)(0x80 | (scalar & 0x3f)), &err);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user