F diff --git a/src/semantics/ast.c b/src/semantics/ast.c
--- a/src/semantics/ast.c
+++ b/src/semantics/ast.c
left_lvalue=(struct Expression_Value_LValue*)left->value;
if(left_lvalue->type!=VALUE_LVALUE)
- { push_translation_error("nonlvalue on left side of . operator",translation_data);return NULL; }
+ { push_translation_error("nonlvalue on left side of . operator",translation_data);return NULL; }
left_type=(struct Type_Struct_Union*)left_lvalue->object->type;
+
+ if(left_type->specifier!=TS_STRUCT && left_type->specifier!=TS_UNION)
+ { push_translation_error("expected struct or union type",translation_data);return NULL; }
+
struct_union=left_type->struct_union;
/*TODO beware const type qualifier*/
struct AST_Binary_Expression* get_struct_union_member_trough_ptr_tree(struct AST_Expression *left,struct token *id,struct Translation_Data *translation_data)
{
- struct Type *left_type;
- struct Type *struct_union_type;
-
- left_type=extract_expresion_value_type(left->value,translation_data);
- if(left_type->specifier!=TS_POINTER)
- {push_translation_error("expected pointer in member trough ptr access",translation_data);return NULL;}
- struct_union_type=((struct Type_Pointer*)left_type)->points_to;
+ return get_struct_union_member_tree(get_indirection_expression_tree(left,translation_data),id,translation_data);
+ }
- if(type_is_struct_union(struct_union_type))
- {push_translation_error("expected pointer to struct or union in member trough ptr access",translation_data);return NULL;}
-
- struct_union=((struct Type_Struct_Union*)struct_union_type)->struct_union;
+ struct AST_Unary_Expression* get_unary_arithmetic_tree(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data)
+ {
+ struct Type *operand_type;
+ struct AST_Unary_Expression *ret;
+
+ operand_type=extract_expresion_value_type(operand->value);
+ if(operation==OP_UNARY_PLUS || operation==OP_UNARY_MINUS)
+ {
+ if(type_is_arithmetic(operand_type))
+ {
+ ret=malloc(sizeof(struct AST_Unary_Expression));
+ ret->type=operand;
+ ret->operand=operand;
+ ret->value=get
- return
+ }else
+ {
+ push_translation_error("expected scalar type for operand in unary operation",translation_data);
+ return NULL;
+ }
+ }
}
struct AST_Conditional_Expression* get_conditional_expression_tree(struct AST_Expression *left,struct AST_Expression *center,struct AST_Expression *right)
F diff --git a/src/semantics/ast.h b/src/semantics/ast.h
--- a/src/semantics/ast.h
+++ b/src/semantics/ast.h
struct AST_Unary_Expression* get_address_expression_tree(struct AST_Expression *operand);
struct AST_Unary_Expression* get_sizeof_by_type_tree(struct Type *type);
struct AST_Unary_Expression* get_cast_expression_tree(struct AST_Expression *operand,struct Type *type,struct Translation_Data *translation_data);
+ struct AST_Unary_Expression* get_unary_arithmetic_tree(struct AST_Expression *operand,enum AST_Type operation,struct Translation_Data *translation_data);
+
struct AST_Constant* get_constant_tree(struct Expression_Value *value);