Skip to content

Commit

Permalink
warning removal remaining 671 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
thradams committed Oct 5, 2024
1 parent 4ea0ee6 commit 9aab416
Show file tree
Hide file tree
Showing 5 changed files with 1,560 additions and 1,445 deletions.
93 changes: 62 additions & 31 deletions src/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -6821,14 +6821,14 @@ struct token_list control_line(struct preprocessor_ctx* ctx, struct token_list*

struct macro_parameter* _Owner _Opt p_macro_parameter = calloc(1, sizeof * p_macro_parameter);
if (p_macro_parameter == NULL) throw;
char* _Owner _Opt temp = strdup("__VA_ARGS__");
if (temp == NULL)
char* _Owner _Opt temp2 = strdup("__VA_ARGS__");
if (temp2 == NULL)
{
macro_delete(macro);
macro_parameters_delete(p_macro_parameter);
throw;
}
p_macro_parameter->name = temp;
p_macro_parameter->name = temp2;
macro->parameters = p_macro_parameter;

token_list_destroy(&macro->replacement_list);
Expand Down Expand Up @@ -7171,7 +7171,14 @@ static struct macro_argument_list collect_macro_arguments(struct preprocessor_ct
{
throw;
}
p_argument->name = strdup(p_current_parameter->name);
char* _Owner _Opt name_temp = strdup(p_current_parameter->name);
if (name_temp == NULL)
{
macro_argument_delete(p_argument);
throw;
}

p_argument->name = name_temp;
argument_list_add(&macro_argument_list, p_argument);
}
match_token_level(&macro_argument_list.tokens, input_list, ')', level, ctx);
Expand All @@ -7182,8 +7189,15 @@ static struct macro_argument_list collect_macro_arguments(struct preprocessor_ct
{
throw;
}
char* _Opt _Owner temp2 = strdup(p_current_parameter->name);
if (temp2 == NULL)
{
macro_argument_delete(p_argument);
throw;
}

p_argument->name = temp2;

p_argument->name = strdup(p_current_parameter->name);
while (input_list->head != NULL)
{
if (input_list->head->type == '(')
Expand All @@ -7207,14 +7221,21 @@ static struct macro_argument_list collect_macro_arguments(struct preprocessor_ct
{
if (strcmp(p_current_parameter->name, "__VA_ARGS__") == 0)
{
//adicionamos este argumento como sendo vazio
//we add this argument as being empty
p_argument = calloc(1, sizeof(struct macro_argument));
if (p_argument == NULL)
{
throw;
}

p_argument->name = strdup(p_current_parameter->name);
char* _Owner _Opt argument_name = strdup(p_current_parameter->name);
if (argument_name == NULL)
{
macro_argument_delete(p_argument);
throw;
}

p_argument->name = argument_name;

argument_list_add(&macro_argument_list, p_argument);
p_argument = NULL; //MOVED
Expand All @@ -7226,7 +7247,6 @@ static struct macro_argument_list collect_macro_arguments(struct preprocessor_ct
}
}


break;
}
else
Expand Down Expand Up @@ -7262,7 +7282,14 @@ static struct macro_argument_list collect_macro_arguments(struct preprocessor_ct
p_argument = NULL; //DELETED
throw;
}
p_argument->name = strdup(p_current_parameter->name);

char * temp3 = strdup(p_current_parameter->name);
if (temp3 == NULL)
{
macro_argument_delete(p_argument);
throw;
}
p_argument->name = temp3;
}
}
else
Expand Down Expand Up @@ -7663,9 +7690,9 @@ struct token_list replacement_list_reexamination(struct preprocessor_ctx* ctx,

if (ctx->conditional_inclusion)
{
/*
Quando estamos expandindo em condinonal inclusion o defined macro ou defined (macro)
não é expandido e é considerado depois
/*
When we are expanding in conditional inclusion the defined macro or defined (macro)
is not expanded and is considered later
*/
if (r.tail &&
r.tail->type == TK_IDENTIFIER &&
Expand Down Expand Up @@ -8180,6 +8207,7 @@ static struct token_list text_line(struct preprocessor_ctx* ctx, struct token_li
if (is_final)
{
prematch(&r, input_list);
assert(r.tail != NULL);
r.tail->flags |= TK_FLAG_FINAL;
}
else
Expand Down Expand Up @@ -10403,7 +10431,7 @@ int test_line_continuation()


return 0;
}
}

int stringify_test()
{
Expand Down Expand Up @@ -14835,7 +14863,7 @@ struct declarator* _Opt find_declarator(const struct parser_ctx* ctx, const char
struct enumerator* _Opt find_enumerator(const struct parser_ctx* ctx, const char* lexeme, struct scope** _Opt ppscope_opt);
struct map_entry* _Opt find_variables(const struct parser_ctx* ctx, const char* lexeme, struct scope* _Opt * _Opt ppscope_opt);

struct struct_or_union_specifier* _Opt find_struct_or_union_specifier(struct parser_ctx* ctx, const char* lexeme);
struct struct_or_union_specifier* _Opt find_struct_or_union_specifier(const struct parser_ctx* ctx, const char* lexeme);

void print_scope(struct scope_list* e);

Expand Down Expand Up @@ -14970,7 +14998,7 @@ struct attribute_specifier_sequence
struct attribute_specifier* _Owner _Opt head;
struct attribute_specifier* _Opt tail;
};
struct attribute_specifier_sequence* _Owner attribute_specifier_sequence_opt(struct parser_ctx* ctx);
struct attribute_specifier_sequence* _Owner _Opt attribute_specifier_sequence_opt(struct parser_ctx* ctx);
void attribute_specifier_sequence_delete(struct attribute_specifier_sequence* _Owner _Opt p);
void attribute_specifier_sequence_add(struct attribute_specifier_sequence* list, struct attribute_specifier* _Owner p_item);

Expand Down Expand Up @@ -27816,7 +27844,7 @@ struct enum_specifier* _Opt find_enum_specifier(struct parser_ctx* ctx, const ch
return best; // mesmo que nao seja tao completo vamos retornar.
}

struct struct_or_union_specifier* _Opt find_struct_or_union_specifier(struct parser_ctx* ctx, const char* lexeme)
struct struct_or_union_specifier* _Opt find_struct_or_union_specifier(const struct parser_ctx* ctx, const char* lexeme)
{
struct struct_or_union_specifier* _Opt p = NULL;
struct scope* _Opt scope = ctx->scopes.tail;
Expand Down Expand Up @@ -28594,7 +28622,6 @@ static void parser_skip_blanks(struct parser_ctx* ctx)
{
while (ctx->current && !(ctx->current->flags & TK_FLAG_FINAL))
{

if (ctx->current->type == TK_PRAGMA)
{
/*only active block have TK_PRAGMA*/
Expand Down Expand Up @@ -29494,6 +29521,8 @@ struct init_declarator* _Owner _Opt init_declarator(struct parser_ctx* ctx,

}

//init declarators have names
assert(p_init_declarator->p_declarator->name_opt != NULL);

const char* _Opt name = p_init_declarator->p_declarator->name_opt->lexeme;
if (name)
Expand Down Expand Up @@ -29744,7 +29773,7 @@ struct init_declarator* _Owner _Opt init_declarator(struct parser_ctx* ctx,
p_init_declarator->p_declarator->first_token_opt, NULL,
"static or type qualifiers are not allowed in non-parameter array declarator");
}
else
else if (p_init_declarator->initializer)
{
compiler_diagnostic_message(C_ERROR_STATIC_OR_TYPE_QUALIFIERS_NOT_ALLOWED_IN_NON_PARAMETER,
ctx,
Expand All @@ -29763,7 +29792,7 @@ struct init_declarator* _Owner _Opt init_declarator(struct parser_ctx* ctx,
p_init_declarator->p_declarator->first_token_opt, NULL,
"_Obj_owner qualifier can only be used with pointers");
}
else
else if (p_init_declarator->initializer)
{
compiler_diagnostic_message(C_ERROR_OBJ_OWNER_CAN_BE_USED_ONLY_IN_POINTER,
ctx,
Expand Down Expand Up @@ -31147,6 +31176,7 @@ void type_specifier_qualifier_delete(struct type_specifier_qualifier* _Owner _Op
free(p);
}
}

struct type_specifier_qualifier* _Owner _Opt type_specifier_qualifier(struct parser_ctx* ctx)
{
struct type_specifier_qualifier* _Owner _Opt type_specifier_qualifier = NULL;
Expand Down Expand Up @@ -31268,7 +31298,6 @@ struct enum_specifier* _Owner _Opt enum_specifier(struct parser_ctx* ctx)
p_enum_specifier->attribute_specifier_sequence_opt =
attribute_specifier_sequence_opt(ctx);


if (ctx->current == NULL)
{
unexpected_end_of_file(ctx);
Expand All @@ -31279,7 +31308,6 @@ struct enum_specifier* _Owner _Opt enum_specifier(struct parser_ctx* ctx)
{
snprintf(p_enum_specifier->tag_name, sizeof p_enum_specifier->tag_name, "%s", ctx->current->lexeme);


p_enum_specifier->tag_token = ctx->current;
parser_match(ctx);
}
Expand Down Expand Up @@ -31377,8 +31405,6 @@ struct enum_specifier* _Owner _Opt enum_specifier(struct parser_ctx* ctx)
//throw;
//}
}


}
catch
{
Expand Down Expand Up @@ -31611,6 +31637,7 @@ void atomic_type_specifier_delete(struct atomic_type_specifier* _Owner _Opt p)
free(p);
}
}

struct atomic_type_specifier* _Owner _Opt atomic_type_specifier(struct parser_ctx* ctx)
{
//'_Atomic' '(' type_name ')'
Expand Down Expand Up @@ -31821,7 +31848,6 @@ struct declarator* _Owner _Opt declarator(struct parser_ctx* ctx,
pointer_opt direct-declarator
*/


struct declarator* _Owner _Opt p_declarator = NULL;
try
{
Expand Down Expand Up @@ -31852,7 +31878,6 @@ struct declarator* _Owner _Opt declarator(struct parser_ctx* ctx,
else
{
/*empty declarator*/

p_declarator->last_token_opt = p_declarator->first_token_opt;
p_declarator->first_token_opt = NULL; /*this is the way we can know...first is null*/
}
Expand Down Expand Up @@ -31896,6 +31921,7 @@ void function_declarator_delete(struct function_declarator* _Owner _Opt p)
free(p);
}
}

void direct_declarator_delete(struct direct_declarator* _Owner _Opt p)
{
if (p)
Expand All @@ -31908,6 +31934,7 @@ void direct_declarator_delete(struct direct_declarator* _Owner _Opt p)
free(p);
}
}

struct direct_declarator* _Owner _Opt direct_declarator(struct parser_ctx* ctx,
const struct specifier_qualifier_list* _Opt p_specifier_qualifier_list,
struct declaration_specifiers* _Opt p_declaration_specifiers,
Expand Down Expand Up @@ -32232,6 +32259,7 @@ void pointer_delete(struct pointer* _Owner _Opt p)
free(p);
}
}

struct pointer* _Owner _Opt pointer_opt(struct parser_ctx* ctx)
{
struct pointer* _Owner _Opt p = NULL;
Expand Down Expand Up @@ -32379,12 +32407,10 @@ struct parameter_type_list* _Owner _Opt parameter_type_list(struct parser_ctx* c

// parameter_list
// parameter_list ',' '...'
p_parameter_type_list->parameter_list = parameter_list(ctx);

p_parameter_type_list->parameter_list = parameter_list(ctx);
if (p_parameter_type_list->parameter_list == NULL) throw;

if (p_parameter_type_list->parameter_list &&
p_parameter_type_list->parameter_list->head ==
if (p_parameter_type_list->parameter_list->head ==
p_parameter_type_list->parameter_list->tail)
{
if (type_is_void(&p_parameter_type_list->parameter_list->head->declarator->type))
Expand Down Expand Up @@ -32700,7 +32726,9 @@ void print_direct_declarator(struct osstream* ss, struct direct_declarator* p_di

print_declaration_specifiers(ss, p_parameter_declaration->declaration_specifiers);
ss_fprintf(ss, " ");
print_declarator(ss, p_parameter_declaration->declarator, is_abstract);

if (p_parameter_declaration->declarator)
print_declarator(ss, p_parameter_declaration->declarator, is_abstract);

p_parameter_declaration = p_parameter_declaration->next;
}
Expand Down Expand Up @@ -32830,6 +32858,7 @@ void braced_initializer_delete(struct braced_initializer* _Owner _Opt p)
free(p);
}
}

struct braced_initializer* _Owner _Opt braced_initializer(struct parser_ctx* ctx)
{
/*
Expand Down Expand Up @@ -33059,6 +33088,7 @@ void designation_delete(struct designation* _Owner _Opt p)
free(p);
}
}

struct designation* _Owner _Opt designation(struct parser_ctx* ctx)
{
// designator_list '='
Expand Down Expand Up @@ -33118,6 +33148,7 @@ void designator_list_delete(struct designator_list* _Owner _Opt p)
free(p);
}
}

struct designator_list* _Owner _Opt designator_list(struct parser_ctx* ctx)
{
// designator
Expand Down Expand Up @@ -33798,7 +33829,7 @@ void attribute_list_destroy(struct attribute_list* _Obj_owner p)
}
}

void attribute_list_delete(struct attribute_list* _Owner p)
void attribute_list_delete(struct attribute_list* _Owner _Opt p)
{
if (p)
{
Expand Down
Loading

0 comments on commit 9aab416

Please sign in to comment.