X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-semantic-validator.c;h=be5ed8f440e1b51c5672962f0684bc46ebf875d1;hb=b7e35badc2eac52e27b802a9078bfb7c8f3b04a7;hp=6385b0bd3ffb2e76c61f3abe059083a8d53cd871;hpb=3e11b713fa76482be45bff5b067cfab5ab6e9be1;p=babeltrace.git diff --git a/formats/ctf/metadata/ctf-visitor-semantic-validator.c b/formats/ctf/metadata/ctf-visitor-semantic-validator.c index 6385b0bd..be5ed8f4 100644 --- a/formats/ctf/metadata/ctf-visitor-semantic-validator.c +++ b/formats/ctf/metadata/ctf-visitor-semantic-validator.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "ctf-scanner.h" #include "ctf-parser.h" @@ -69,14 +70,27 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) * We are the length of a type declarator. */ switch (node->u.unary_expression.type) { - case UNARY_SIGNED_CONSTANT: case UNARY_UNSIGNED_CONSTANT: break; default: - fprintf(fd, "[error]: semantic error (children of type declarator and enum can only be numeric constants)\n"); + fprintf(fd, "[error]: semantic error (children of type declarator and enum can only be unsigned numeric constants)\n"); goto errperm; } break; /* OK */ + + case NODE_STRUCT: + /* + * We are the size of a struct align attribute. + */ + switch (node->u.unary_expression.type) { + case UNARY_UNSIGNED_CONSTANT: + break; + default: + fprintf(fd, "[error]: semantic error (structure alignment attribute can only be unsigned numeric constants)\n"); + goto errperm; + } + break; + case NODE_ENUMERATOR: /* The enumerator's parent has validated its validity already. */ break; /* OK */ @@ -105,7 +119,6 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node) case NODE_ENUM: case NODE_STRUCT_OR_VARIANT_DECLARATION: case NODE_VARIANT: - case NODE_STRUCT: default: goto errinval; } @@ -862,15 +875,15 @@ int ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node) * take the safe route and recreate them at each validation, just in * case the structure has changed. */ - fprintf(fd, "CTF visitor: parent links creation... "); + printf_verbose("CTF visitor: parent links creation... "); ret = ctf_visitor_parent_links(fd, depth, node); if (ret) return ret; - fprintf(fd, "done.\n"); - fprintf(fd, "CTF visitor: semantic check... "); + printf_verbose("done.\n"); + printf_verbose("CTF visitor: semantic check... "); ret = _ctf_visitor_semantic_check(fd, depth, node); if (ret) return ret; - fprintf(fd, "done.\n"); + printf_verbose("done.\n"); return ret; }