+ struct ctf_declaration *declaration;
+ struct ctf_type *type;
+
+ type = ctf_type_specifier_visit(fd, depth, head, type_scope,
+ declaration_scope);
+ declaration = type->declaration_new(type, declaration_scope);
+ if (type->id == CTF_TYPE_VARIANT) {
+ struct declaration_variant *variant =
+ container_of(declaration, struct declaration_variant, p);
+ struct declaration *enum_tag =
+ lookup_field_declaration(enum_tag_name, declaration_scope);
+ if (!enum_tag) {
+ fprintf(fd, "[error]: expected enumeration tag field %s for variant\n",
+ enum_tag_name);
+ goto error;
+ }
+ /* TODO find enum tag */
+ ret = variant_declaration_set_tag(variant, enum_tag);
+ }
+ return declaration;
+error:
+ declaration_unref(declaration);
+ type_unref(type);
+ return NULL;