Add enum {} default mapping to "int" type
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 28 Apr 2011 23:45:49 +0000 (19:45 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 28 Apr 2011 23:45:49 +0000 (19:45 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/metadata/ctf-test/succeed/ctf-test.txt
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
formats/ctf/metadata/ctf-visitor-parent-links.c
formats/ctf/metadata/ctf-visitor-xml.c

index 932db5c9844c3051d6631875540ca65f1c1e975a..34dd8274f863a321637935765be44fa37a1c5444 100644 (file)
@@ -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 */
index 28962abd7281f16e683e163f10cc32810a606cab..a399066afc65b5e72f4368546b3319517f25aec4 100644 (file)
@@ -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;
index 9337dd49b832e9a053f568d6f3b96887ba04bd23..707f03a5c20af4e71fe626985ce68e97b958f9ee 100644 (file)
@@ -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;
index d1c0751c51e3c8c548144c087cd1834c05d6fa52..96145f8b73bf249d797218413ac80dcc942dd457 100644 (file)
@@ -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, "<container_type>\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, "</container_type>\n");
                }
This page took 0.027786 seconds and 4 git commands to generate.