WONKY



LOG | FILES | OVERVIEW


F diff --git a/src/debug/wobler/wobler.c b/src/debug/wobler/wobler.c --- a/src/debug/wobler/wobler.c +++ b/src/debug/wobler/wobler.c
.how_much_time_should_execution_take=0.01,
},
{
+ .filenames={"test_declaration.c"},
+ .test_function=should_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_declaration2.c"},
+ .test_function=should_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
+ .filenames={"test_declaration_error.c"},
+ .test_function=should_not_compile,
+ .how_much_time_should_execution_take=0.01,
+ },
+ {
.filenames={"test_bitfields.c"},
.test_function=should_not_compile,
.how_much_time_should_execution_take=0.01,
F diff --git a/src/frontend/parse/parse_declaration.c b/src/frontend/parse/parse_declaration.c --- a/src/frontend/parse/parse_declaration.c +++ b/src/frontend/parse/parse_declaration.c
Queue_Push(where_to_push,get_type_definition_tree((struct Denoted_Type*)hold));
}else if(hold->denotation==DT_Object)
{
- struct Initialiser *initializer=NULL;
- struct AST_Expression *to_be_initialised;
- struct Denoted_Object *real_type;
-
- real_type=(struct Denoted_Object*)hold;
- to_be_initialised=(struct AST_Expression*)get_designator_tree_from_denoted_object(real_type,translation_data);
- if(get_and_check(translation_data,KW_EQ))
- {
- initializer=parse_initialiser(translation_data,scope,real_type->object->type);
- assert(is_valid_initialiser(initializer));
- }
-
- Queue_Push(where_to_push,get_object_declaration_tree((struct Denoted_Object*)hold,initializer));
-
+ parse_finish_object_declaration(translation_data,scope,(struct Denoted_Object*)hold,where_to_push);
}else
{
/*TODO error*/
Queue_Push(where_to_push,get_function_definition_tree(scope,function,function_body,translation_data));
}
+ void parse_finish_object_declaration(struct Translation_Data *translation_data,struct Scope *scope,struct Denoted_Object *object,struct Queue *where_to_push)
+ {
+ struct Initialiser *initializer=NULL;
+ struct AST_Expression *to_be_initialised;
+
+ to_be_initialised=(struct AST_Expression*)get_designator_tree_from_denoted_object(object,translation_data);
+ if(get_and_check(translation_data,KW_EQ))
+ {
+ initializer=parse_initialiser(translation_data,scope,object->object->type);
+ assert(is_valid_initialiser(initializer));
+ }
+
+ Queue_Push(where_to_push,get_object_declaration_tree(object,initializer));
+ }
struct Denotation_Prototype* parse_specifier_qualifier_list(struct Translation_Data *translation_data,struct Scope *scope)
{
return parse_declaration_specifiers_inner(translation_data,scope,0);
F diff --git a/src/frontend/parse/parse_declaration.h b/src/frontend/parse/parse_declaration.h --- a/src/frontend/parse/parse_declaration.h +++ b/src/frontend/parse/parse_declaration.h
void parse_declaration(struct Translation_Data *translation_data,struct Scope *scope,struct Queue *where_to_push,char parse_function_definitions);
void parse_finish_function_definition(struct Translation_Data *translation_data,struct Scope *scope,struct Denoted_Function *function,struct Queue *where_to_push);
+ void parse_finish_object_declaration(struct Translation_Data *translation_data,struct Scope *scope,struct Denoted_Object *object,struct Queue *where_to_push);
struct Denotation_Prototype* parse_specifier_qualifier_list(struct Translation_Data *translation_data,struct Scope *scope);
struct Denotation_Prototype* parse_declaration_specifiers(struct Translation_Data *translation_data,struct Scope *scope);
struct Denotation_Prototype* parse_declaration_specifiers_inner(struct Translation_Data *translation_data,struct Scope *scope,char parse_storage_class);
F diff --git a/tests/test_declaration.c b/tests/test_declaration.c new file mode 100644 --- /dev/null +++ b/tests/test_declaration.c
+ int a;
+ int b;
+ int c=10;
+
+ struct A
+ {
+ int a;
+ void *b;
+ };
+ int main()
+ {
+ struct A a;
+ a.a=a;
+ a.b=(void*)0;
+
+ return a.a;
+ }
F diff --git a/tests/test_declaration2.c b/tests/test_declaration2.c new file mode 100644 --- /dev/null +++ b/tests/test_declaration2.c
+ int a;
+ int b;
+ void *c;
+ int main()
+ {
+ int c;
+
+ return c;
+ }
F diff --git a/tests/test_declaration_error.c b/tests/test_declaration_error.c new file mode 100644 --- /dev/null +++ b/tests/test_declaration_error.c
+ int main;
+
+
+ int main()
+ {
+ int a;
+ int a;
+ return 0;
+ }