WONKY



LOG | FILES | OVERVIEW


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
if(get_and_check(translation_data,KW_OPEN_CURLY))
{
base->is_finished=1;
- while(parse_struct_declaration(translation_data,(struct Scope*)base->inner_namespace,base->members))
+ while(parse_struct_declaration(translation_data,base))
if(get_and_check(translation_data,KW_CLOSE_CURLY))
return ;
/*TODO error*/
struct-declaration:
specifier-qualifier-list ( struct-declarator )* ;
*/
- char parse_struct_declaration(struct Translation_Data *translation_data,struct Scope *struct_scope,struct Queue* members)
+ char parse_struct_declaration(struct Translation_Data *translation_data,struct Struct_Union *base)
{
struct Denotation_Prototype *prototype;
- struct Denoted *hold;
- prototype=parse_specifier_qualifier_list(translation_data,struct_scope);
+ struct Denoted_Object *hold;
+ prototype=parse_specifier_qualifier_list(translation_data,base->inner_namespace);
while(!get_and_check(translation_data,KW_SEMI_COLUMN))
{
- hold=parse_struct_declarator(translation_data,struct_scope,prototype);
+ hold=parse_struct_declarator(translation_data,base->inner_namespace,prototype);
if(hold!=NULL && hold->denotation!=DT_Error)
{
- Scope_Push(struct_scope,hold,translation_data);
- Queue_Push(members,hold);
+ if(hold->denotation==DT_Object)
+ {
+ Scope_Push(base->inner_namespace,hold,translation_data);
+ Queue_Push(base->members,hold);
+ if(type_is_constant_or_has_constant_member(hold->object->type))
+ base->has_constant_member=1;
+ }else
+ {
+ push_translation_error("non object declaration in struct definition",translation_data);
+ }
}else
{
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_direct_declarator(struct Translation_Data *translation_data,struct Scope *scope,struct Denoted_Base *base);
void parse_direct_declarator_finish(struct Translation_Data *translation_data,struct Scope *scope,struct Denoted_Base *base);
void parse_struct_union_specifier_finish(struct Translation_Data *translation_data,struct Scope *scope,struct Struct_Union *base);
- char parse_struct_declaration(struct Translation_Data *translation_data,struct Scope *struct_scope,struct Queue* members);
+ char parse_struct_declaration(struct Translation_Data *translation_data,struct Struct_Union *base);
struct Denoted* parse_struct_declarator(struct Translation_Data *translation_data,struct Scope *scope,struct Denotation_Prototype *prototype);
void parse_enum_specifier_finish(struct Translation_Data *translation_data,struct Scope *scope,struct Enum *enumeration);
void parse_paramenter_list(struct Translation_Data *translation_data,struct Normal_Scope *function_prototype_scope,struct Queue *parameters);
F diff --git a/src/semantics/value/type.c b/src/semantics/value/type.c --- a/src/semantics/value/type.c +++ b/src/semantics/value/type.c
ret->inner_namespace=(struct Normal_Scope*)get_normal_scope(scope,BLOCK_SCOPE);
ret->is_finished=0;
+ ret->has_constant_member=0;
return ret;
}
{
return (type->specifier==TS_STRUCT || type->specifier==TS_UNION);
}
+ char type_is_constant_or_has_constant_member(struct Type *type)
+ {
+ if(type->specifier==TS_STRUCT || type->specifier==TS_UNION)
+ {
+ if( ((struct Type_Struct_Union*)type)->is_const)
+ {
+ return 1;
+ }else
+ {
+ struct Queue_Node *it;
+ for(it=((struct Type_Struct_Union*)type)->struct_union->members->first;it!=NULL;it=it)
+ {
+ if( type_is_constant_or_has_constant_member(((struct Denoted_Object*)it->data)->object->type))
+ return 1;
+ }
+ return 0;
+ }
+ }else if(type_is_basic(type))
+ {
+ return ((struct Type_Basic*)type)->is_const;
+ }else
+ {
+ return 0;
+ }
+ }
#endif
F diff --git a/src/semantics/value/type.h b/src/semantics/value/type.h --- a/src/semantics/value/type.h +++ b/src/semantics/value/type.h
char type_is_scalar(struct Type *type);
char type_is_aggregate(struct Type *type);
char type_is_struct_union(struct Type *type);
+ char type_is_constant_or_has_constant_member(struct Type *type);