Commit d58c853a authored by Sergio Costas's avatar Sergio Costas

Added full support for ENUMs

parent b165b48b
......@@ -1065,6 +1065,8 @@ class crust(object):
continue
if node.type == "VARIABLE_DEFINITION":
if not node.t_typedef:
if (node.enum_data is not None):
self._process_enum(node, thread_status)
pointers = node.pointer
if node.arrays is not None:
for element in node.arrays:
......@@ -1243,6 +1245,8 @@ class crust(object):
if node.type == "VARIABLE_DEFINITION":
if node.t_typedef:
return self._check_return_block(tree[1:], thread_status)
if (node.enum_data is not None):
self._process_enum(node, thread_status)
varname = node.name
var_defined = self._get_variable_properties(thread_status, node, node.pointer, False)
var_defined["value"] = crust.VALUE_UNINITIALIZED
......
......@@ -135,10 +135,13 @@ void mix_ast_leaves(struct AST *base, struct AST *origin_leaf) {
base->t_ellipsis |= origin_leaf->t_ellipsis;
base->t_label |= origin_leaf->t_label;
if (base->function_params == NULL) {
base->function_params = copy_leaf(origin_leaf->function_params,true);
base->function_params = copy_leaf(origin_leaf->function_params, true);
}
if (base->return_value == NULL) {
base->return_value = copy_leaf(origin_leaf->return_value,false);
base->return_value = copy_leaf(origin_leaf->return_value, false);
}
if (base->enum_data == NULL) {
base->enum_data = copy_leaf(origin_leaf->enum_data, true);
}
//base->t_ |= origin_leaf->t_;
}
......
......@@ -740,6 +740,9 @@ class Test(unittest.TestCase):
def test156TestForContinue3(self):
self._generic_test("unitest/test156.c", [ (crust.crust.MSG_ERROR, "Assignment to '{:s}' at line {:d}, which was already assigned at line {:d}", "param", 12, 12) ])
def test157CheckEnums(self):
self._all_fine_test("unitest/test157.c")
if __name__ == '__main__':
try:
os.remove("error_list.txt")
......
enum {
STATUS1, STATUS2
} status = STATUS1;
void main(int b) {
enum {
MORE1, MORE2
} more = MORE1;
status = STATUS2;
more = MORE2;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment