From: Mathieu Desnoyers Date: Mon, 11 Jul 2011 19:01:55 +0000 (-0400) Subject: Fix abstract array handling X-Git-Tag: v0.1~9^2~3 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=7c7835b045c7457dc13ac83a7af1b1c1df5843cb Fix abstract array handling Signed-off-by: Mathieu Desnoyers --- diff --git a/formats/ctf/metadata/ctf-visitor-parent-links.c b/formats/ctf/metadata/ctf-visitor-parent-links.c index a4476b22..0258fd63 100644 --- a/formats/ctf/metadata/ctf-visitor-parent-links.c +++ b/formats/ctf/metadata/ctf-visitor-parent-links.c @@ -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; diff --git a/formats/ctf/metadata/ctf-visitor-semantic-validator.c b/formats/ctf/metadata/ctf-visitor-semantic-validator.c index 5f72e0b4..b89f7bd7 100644 --- a/formats/ctf/metadata/ctf-visitor-semantic-validator.c +++ b/formats/ctf/metadata/ctf-visitor-semantic-validator.c @@ -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, diff --git a/formats/ctf/metadata/ctf-visitor-xml.c b/formats/ctf/metadata/ctf-visitor-xml.c index 49fa9928..c47bd27d 100644 --- a/formats/ctf/metadata/ctf-visitor-xml.c +++ b/formats/ctf/metadata/ctf-visitor-xml.c @@ -313,7 +313,12 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node print_tabs(fd, depth); fprintf(fd, "\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, "\n"); + print_tabs(fd, depth); + fprintf(fd, "\n"); + } else if (!cds_list_empty(&node->u.type_declarator.u.nested.length)) { print_tabs(fd, depth); fprintf(fd, "\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, "\n"); } - if (node->u.type_declarator.u.nested.abstract_array) { - print_tabs(fd, depth); - fprintf(fd, "\n"); - print_tabs(fd, depth); - fprintf(fd, "\n"); - } if (node->u.type_declarator.bitfield_len) { print_tabs(fd, depth); fprintf(fd, "\n");