Fix abstract array handling
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 11 Jul 2011 19:01:55 +0000 (15:01 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 11 Jul 2011 19:01:55 +0000 (15:01 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/metadata/ctf-visitor-parent-links.c
formats/ctf/metadata/ctf-visitor-semantic-validator.c
formats/ctf/metadata/ctf-visitor-xml.c

index a4476b22e648029ff5f8d92a193b5f9672fefed9..0258fd63591276fff956ebc733c6258c0e0e7aa6 100644 (file)
@@ -147,12 +147,14 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
-                                       siblings) {
-                       iter->parent = node;
-                       ret = ctf_visitor_parent_links(fd, depth + 1, iter);
-                       if (ret)
-                               return ret;
+               if (!node->u.type_declarator.u.nested.abstract_array) {
+                       cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
+                                               siblings) {
+                               iter->parent = node;
+                               ret = ctf_visitor_parent_links(fd, depth + 1, iter);
+                               if (ret)
+                                       return ret;
+                       }
                }
                if (node->u.type_declarator.bitfield_len) {
                        node->u.type_declarator.bitfield_len = node;
index 5f72e0b42b1652c9a9929ceeb59b91733d282988..b89f7bd7660d0d363faf4dab4dd77d009bb57320 100644 (file)
@@ -363,15 +363,22 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
-                                       siblings) {
-                       if (iter->type != NODE_UNARY_EXPRESSION) {
-                               fprintf(fd, "[error] %s: expecting unary expression as length\n", __func__);
+               if (!node->u.type_declarator.u.nested.abstract_array) {
+                       cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
+                                               siblings) {
+                               if (iter->type != NODE_UNARY_EXPRESSION) {
+                                       fprintf(fd, "[error] %s: expecting unary expression as length\n", __func__);
+                                       return -EINVAL;
+                               }
+                               ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
+                               if (ret)
+                                       return ret;
+                       }
+               } else {
+                       if (node->parent->type == NODE_TYPEALIAS_TARGET) {
+                               fprintf(fd, "[error] %s: abstract array declarator not permitted as target of typealias\n", __func__);
                                return -EINVAL;
                        }
-                       ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
-                       if (ret)
-                               return ret;
                }
                if (node->u.type_declarator.bitfield_len) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1,
index 49fa992817906dfd66d93d14b33b1de3794f9a42..c47bd27d8ed61ae0c64bf3f7939f443b239fdfd2 100644 (file)
@@ -313,7 +313,12 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node
                        print_tabs(fd, depth);
                        fprintf(fd, "</type_declarator>\n");
                }
-               if (!cds_list_empty(&node->u.type_declarator.u.nested.length)) {
+               if (node->u.type_declarator.u.nested.abstract_array) {
+                       print_tabs(fd, depth);
+                       fprintf(fd, "<length>\n");
+                       print_tabs(fd, depth);
+                       fprintf(fd, "</length>\n");
+               } else if (!cds_list_empty(&node->u.type_declarator.u.nested.length)) {
                        print_tabs(fd, depth);
                        fprintf(fd, "<length>\n");
                        cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
@@ -325,12 +330,6 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node
                        print_tabs(fd, depth);
                        fprintf(fd, "</length>\n");
                }
-               if (node->u.type_declarator.u.nested.abstract_array) {
-                       print_tabs(fd, depth);
-                       fprintf(fd, "<length>\n");
-                       print_tabs(fd, depth);
-                       fprintf(fd, "</length>\n");
-               }
                if (node->u.type_declarator.bitfield_len) {
                        print_tabs(fd, depth);
                        fprintf(fd, "<bitfield_len>\n");
This page took 0.027963 seconds and 4 git commands to generate.