WONKY



LOG | FILES | OVERVIEW


F diff --git a/doc/todo.txt b/doc/todo.txt --- a/doc/todo.txt +++ b/doc/todo.txt
Make multiple definitions check
Make variadic functions and macros
Implement declarations in for cycle - for(int i=0;i<10;++i)
+ Make wonky_calloc check for overflows
F diff --git a/src/debug/wobler/wobler_tests.h b/src/debug/wobler/wobler_tests.h --- a/src/debug/wobler/wobler_tests.h +++ b/src/debug/wobler/wobler_tests.h
.how_much_time_should_execution_take=TEST_TIME_BASELINE,
},
{
+ .filenames={"test_for_cycle_declaration.c"},
+ .test_function=should_compile,
+ .how_much_time_should_execution_take=TEST_TIME_BASELINE,
+ },
+ {
.filenames={"test_declaration_speed.c"},
.test_function=should_compile,
.how_much_time_should_execution_take=TEST_TIME_BASELINE,
F diff --git a/src/frontend/parse/parse_statement.c b/src/frontend/parse/parse_statement.c --- a/src/frontend/parse/parse_statement.c +++ b/src/frontend/parse/parse_statement.c
}
hold->initialisation=parse_expression_statement(translation_data,scope,parse_data);
+ if(hold->initialisation->type==ERROR)
+ push_translation_error("expected expression or declaration in for loop initialisation",translation_data);
+
hold->condition=parse_expression_statement(translation_data,scope,parse_data);
if(get_and_check(translation_data,KW_CLOSE_NORMAL))
F diff --git a/src/misc/wonky_malloc.c b/src/misc/wonky_malloc.c --- a/src/misc/wonky_malloc.c +++ b/src/misc/wonky_malloc.c
void* wonky_malloc(size_t size)
{
if(wonky_memory.generic->capacity - wonky_memory.generic->size <= size)
- {
wonky_memory.generic=get_memory_segment(wonky_memory.generic,size);
- }
+
wonky_memory.generic->size+=size;
return wonky_memory.generic->data + wonky_memory.generic->size - size;
}
void* wonky_calloc(size_t nmemb,size_t size)
{
if(wonky_memory.generic->capacity - wonky_memory.generic->size <= size*nmemb)
- {
wonky_memory.generic=get_memory_segment(wonky_memory.generic,size*nmemb);
- }
+
for(size_t i=0;i<size*nmemb;++i)
- {
- wonky_memory.generic->data[i+wonky_memory.generic->size]=0;
- }
+ wonky_memory.generic->data[i+wonky_memory.generic->size]=0;
+
wonky_memory.generic->size+=nmemb*size;
return wonky_memory.generic->data + wonky_memory.generic->size - nmemb*size;
}
wonky_memory.map_nodes=calloc_memory_segment(wonky_memory.map_nodes,NUMBER_OF_MAP_NODES_IN_INCREMENTATION_OF_MAP_MEMORY_SEGMENT,sizeof(struct Map));
++wonky_memory.map_nodes->size;
- return (struct Map*) (wonky_memory.map_nodes->data + wonky_memory.map_nodes->size*(sizeof(struct Map)-1));
+ return (struct Map*) (wonky_memory.map_nodes->data + (wonky_memory.map_nodes->size-1)*sizeof(struct Map));
}
struct token* wonky_malloc_token()
{
F diff --git a/src/semantics/ast.c b/src/semantics/ast.c --- a/src/semantics/ast.c +++ b/src/semantics/ast.c
struct Type *expression_type;
struct Type_Array *array_type;
+ if(expression->type==ERROR)
+ return expression;
+
expression_type=extract_expresion_value_type(expression->value,translation_data);
if(expression_type->specifier==TS_ARRAY)
{
struct AST_Unary_Expression* get_prefix_inc_dec_tree(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data)
{
struct Type *operand_type;
+
+ if(operand->type==ERROR)
+ return (struct AST_Unary_Expression*)operand;
+
operand=get_degraded_array_expression_if_it_has_the_right_type(operand,translation_data);
operand_type=extract_expresion_value_type(operand->value,translation_data);
if(constraint_check_prefix_inc_dec_expression(operand,operation,translation_data))
F diff --git a/tests/test_for_cycle_declaration.c b/tests/test_for_cycle_declaration.c new file mode 100644 --- /dev/null +++ b/tests/test_for_cycle_declaration.c
+ int main()
+ {
+ for(int i=0;i<10;++i)
+ i;
+ return 0;
+ }