From: Mathieu Desnoyers Date: Thu, 28 Apr 2011 23:45:49 +0000 (-0400) Subject: Add enum {} default mapping to "int" type X-Git-Tag: v0.1~129 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=6743829ac9d7ae22c8bcc28b6ad162dd3d0b2104 Add enum {} default mapping to "int" type Signed-off-by: Mathieu Desnoyers --- diff --git a/formats/ctf/metadata/ctf-test/succeed/ctf-test.txt b/formats/ctf/metadata/ctf-test/succeed/ctf-test.txt index 932db5c9..34dd8274 100644 --- a/formats/ctf/metadata/ctf-test/succeed/ctf-test.txt +++ b/formats/ctf/metadata/ctf-test/succeed/ctf-test.txt @@ -24,6 +24,8 @@ enum name4 : unsigned long { enum name5 : long { "int" = 1, }; +enum name6 { "int" = 1, }; + typealias floating_point { exp_dig = 8; /* sizeof(float) * CHAR_BIT - FLT_MANT_DIG */ mant_dig = 24; /* FLT_MANT_DIG */ diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index 28962abd..a399066a 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -845,15 +845,19 @@ struct declaration *ctf_declaration_enum_visit(FILE *fd, int depth, } } if (!container_type) { - fprintf(fd, "[error] %s: missing container type for enumeration\n", __func__); - return NULL; - + declaration = lookup_declaration(g_quark_from_static_string("int"), + declaration_scope); + if (!declaration) { + fprintf(fd, "[error] %s: \"int\" type declaration missing for enumeration\n", __func__); + return NULL; + } + } else { + declaration = ctf_type_declarator_visit(fd, depth, + container_type, + &dummy_id, NULL, + declaration_scope, + NULL, trace); } - declaration = ctf_type_declarator_visit(fd, depth, - container_type, - &dummy_id, NULL, - declaration_scope, - NULL, trace); if (!declaration) { fprintf(fd, "[error] %s: unable to create container type for enumeration\n", __func__); return NULL; diff --git a/formats/ctf/metadata/ctf-visitor-parent-links.c b/formats/ctf/metadata/ctf-visitor-parent-links.c index 9337dd49..707f03a5 100644 --- a/formats/ctf/metadata/ctf-visitor-parent-links.c +++ b/formats/ctf/metadata/ctf-visitor-parent-links.c @@ -358,9 +358,11 @@ int ctf_visitor_parent_links(FILE *fd, int depth, struct ctf_node *node) break; case NODE_ENUM: depth++; - ret = ctf_visitor_parent_links(fd, depth + 1, node->u._enum.container_type); - if (ret) - return ret; + if (node->u._enum.container_type) { + ret = ctf_visitor_parent_links(fd, depth + 1, node->u._enum.container_type); + if (ret) + return ret; + } cds_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) { iter->parent = node; diff --git a/formats/ctf/metadata/ctf-visitor-xml.c b/formats/ctf/metadata/ctf-visitor-xml.c index d1c0751c..96145f8b 100644 --- a/formats/ctf/metadata/ctf-visitor-xml.c +++ b/formats/ctf/metadata/ctf-visitor-xml.c @@ -609,12 +609,9 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node) if (node->u._enum.container_type) { print_tabs(fd, depth); fprintf(fd, "\n"); - } - - ret = ctf_visitor_print_xml(fd, depth + 1, node->u._enum.container_type); - if (ret) - return ret; - if (node->u._enum.container_type) { + ret = ctf_visitor_print_xml(fd, depth + 1, node->u._enum.container_type); + if (ret) + return ret; print_tabs(fd, depth); fprintf(fd, "\n"); }