#include <glib.h>
#include <inttypes.h>
#include <errno.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/list.h>
#include "ctf-scanner.h"
#include "ctf-parser.h"
case NODE_ROOT:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
+ case NODE_CLOCK:
case NODE_TYPEDEF:
case NODE_TYPEALIAS_TARGET:
case NODE_TYPEALIAS_ALIAS:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
+ case NODE_CLOCK:
case NODE_UNARY_EXPRESSION:
case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
case NODE_ROOT:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
+ case NODE_CLOCK:
case NODE_UNARY_EXPRESSION:
case NODE_TYPEALIAS:
case NODE_TYPE_SPECIFIER:
*/
if (node->u.type_declarator.type == TYPEDEC_NESTED)
goto errperm;
- switch (node->u.type_declarator.type) {
- case TYPESPEC_FLOATING_POINT:
- case TYPESPEC_INTEGER:
- case TYPESPEC_STRING:
- case TYPESPEC_STRUCT:
- case TYPESPEC_VARIANT:
- case TYPESPEC_ENUM:
- if (cds_list_empty(&node->u.type_declarator.pointers))
- goto errperm;
- break;
- default:
- break;
+ cds_list_for_each_entry(iter, &node->parent->u.typealias_alias.type_specifier_list->u.type_specifier_list.head,
+ siblings) {
+ switch (iter->u.type_specifier.type) {
+ case TYPESPEC_FLOATING_POINT:
+ case TYPESPEC_INTEGER:
+ case TYPESPEC_STRING:
+ case TYPESPEC_STRUCT:
+ case TYPESPEC_VARIANT:
+ case TYPESPEC_ENUM:
+ if (cds_list_empty(&node->u.type_declarator.pointers))
+ goto errperm;
+ break;
+ default:
+ break;
+ }
}
if (node->u.type_declarator.type == TYPEDEC_ID &&
node->u.type_declarator.u.id != NULL)
case NODE_ROOT:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
+ case NODE_CLOCK:
case NODE_CTF_EXPRESSION:
case NODE_UNARY_EXPRESSION:
case NODE_TYPEALIAS:
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,
return ret;
}
break;
+ case NODE_ENV:
+ switch (node->parent->type) {
+ case NODE_ROOT:
+ break; /* OK */
+ default:
+ goto errinval;
+ }
+
+ cds_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
+ ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
+ if (ret)
+ return ret;
+ }
+ break;
case NODE_TRACE:
switch (node->parent->type) {
case NODE_ROOT:
return ret;
}
break;
+ case NODE_CLOCK:
+ switch (node->parent->type) {
+ case NODE_ROOT:
+ break; /* OK */
+ default:
+ goto errinval;
+ }
+
+ cds_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) {
+ ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
+ if (ret)
+ return ret;
+ }
+ break;
+
case NODE_CTF_EXPRESSION:
switch (node->parent->type) {
case NODE_ROOT:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
+ case NODE_CLOCK:
case NODE_FLOATING_POINT:
case NODE_INTEGER:
case NODE_STRING:
case NODE_STRING:
case NODE_ENUMERATOR:
case NODE_ENUM:
+ case NODE_CLOCK:
+ case NODE_ENV:
default:
goto errinval;
}
case NODE_STRING:
case NODE_ENUMERATOR:
case NODE_ENUM:
+ case NODE_CLOCK:
+ case NODE_ENV:
default:
goto errinval;
}