return (ctf_set_errno (fp, ECTF_NOPARENT));
/* Promote root-visible forwards to structs/unions. */
- if (name != NULL)
+ if (name != NULL && root_flag == CTF_ADD_ROOT)
type = ctf_lookup_by_rawname (fp, kind, name);
if (type > 0)
return (ctf_set_errno (fp, ECTF_NOPARENT));
/* Promote root-visible forwards to enums. */
- if (name != NULL)
+ if (name != NULL && flag == CTF_ADD_ROOT)
type = ctf_lookup_by_rawname (fp, kind, name);
/* Prohibit promotion if this type was ctf_open()ed. */
enums or forwards to them. (This includes other slices: you cannot slice a
slice, which would be a useless thing to do anyway.) */
- if (name != NULL)
+ if (name != NULL && flag == CTF_ADD_ROOT)
type = ctf_lookup_by_rawname (fp, CTF_K_ENUM, name);
if (type != 0)