#include <stdarg.h>
#include <nidl.h>
#include <checker.h>
#include <chkichar.h>
#include <acf_y.h>
#include <ast.h>
#include <astp.h>
#include <command.h>
#include <errors.h>
#include <message.h>
extern const char *acf_keyword_lookup(
int token_value
);
extern int error_count;
static boolean *cmd_opt;
static void **cmd_val;
static void type_check(
AST_type_n_t *type_p,
ASTP_node_t *node_p,
AST_interface_n_t *int_p
);
boolean CHK_struct_is_all_byte_fields
(
AST_structure_n_t *struct_p
)
{
AST_field_n_t *field_p;
for (field_p = struct_p->fields ; field_p != NULL ; field_p = field_p->next)
if (field_p->type->kind != AST_byte_k)
return FALSE;
return TRUE;
}
static boolean type_is_string
(
AST_type_n_t *type_p
)
{
unsigned short index_count;
AST_type_n_t *base_type_p;
if (type_p->kind == AST_array_k)
{
index_count = type_p->type_structure.array->index_count;
base_type_p = type_p->type_structure.array->element_type;
}
else if (type_p->kind == AST_pointer_k)
{
index_count = 1;
base_type_p = type_p->type_structure.pointer->pointee_type;
}
else
return FALSE;
if (index_count == 1
&& (base_type_p->kind == AST_character_k
|| base_type_p->kind == AST_byte_k
|| base_type_p->kind == AST_short_unsigned_k
|| base_type_p->kind == AST_long_unsigned_k
|| (base_type_p->kind == AST_structure_k
&& CHK_struct_is_all_byte_fields
(base_type_p->type_structure.structure))))
return TRUE;
return FALSE;
}
static boolean type_is_v1_string
(
AST_type_n_t *type_p
)
{
AST_array_n_t *array_p;
AST_array_index_n_t *index_p;
if (type_p->kind != AST_array_k)
return FALSE;
array_p = type_p->type_structure.array;
if (array_p->element_type->kind != AST_character_k)
return FALSE;
index_p = &array_p->index_vec[array_p->index_count - 1];
if (!AST_CONFORMANT_SET(type_p)
&& index_p->lower_bound != NULL
&& index_p->lower_bound->kind == AST_int_const_k
&& index_p->lower_bound->value.int_val == 0
&& index_p->upper_bound != NULL
&& index_p->upper_bound->kind == AST_int_const_k)
return TRUE;
return FALSE;
}
static AST_type_n_t * type_xmit_type
(
AST_type_n_t *type_p
)
{
while (type_p->xmit_as_type != NULL)
type_p = type_p->xmit_as_type;
return type_p;
}
static boolean array_is_conformant_upper
(
AST_array_n_t *array_p
)
{
AST_array_index_n_t *index_p;
int i;
index_p = array_p->index_vec;
for (i = 1, index_p++ ; i < array_p->index_count ; i++, index_p++)
{
if (!AST_FIXED_LOWER_SET(index_p)
|| !AST_FIXED_UPPER_SET(index_p))
return TRUE;
}
return FALSE;
}
static boolean array_is_large
(
AST_array_n_t *array_p
)
{
AST_array_index_n_t *index_p;
int i;
long dim_size;
long elem_cnt;
index_p = array_p->index_vec;
elem_cnt = 1;
for (i = 0 ; i < array_p->index_count ; i++, index_p++)
{
if (AST_FIXED_LOWER_SET(index_p)
&& AST_FIXED_UPPER_SET(index_p))
{
dim_size = index_p->upper_bound->value.int_val -
index_p->lower_bound->value.int_val + 1;
if (dim_size > 65535)
return TRUE;
elem_cnt = elem_cnt * dim_size;
if (elem_cnt > 65535)
return TRUE;
}
}
return FALSE;
}
static boolean array_has_open_lb
(
AST_array_n_t *array_p
)
{
AST_array_index_n_t *index_p;
int i;
index_p = array_p->index_vec;
for (i = 0 ; i < array_p->index_count ; i++, index_p++)
if (!AST_FIXED_LOWER_SET(index_p))
return TRUE;
return FALSE;
}
AST_type_n_t * param_follow_ref_ptr
(
AST_parameter_n_t *param_p,
CHK_follow_t mode
)
{
AST_type_n_t *type_p;
AST_type_n_t *ptee_type_p;
type_p = param_p->type;
if (type_p->kind != AST_pointer_k)
return type_p;
ptee_type_p = type_p->type_structure.pointer->pointee_type;
if (param_p == param_p->uplink->result
|| ptee_type_p->kind == AST_void_k
|| ptee_type_p->kind == AST_function_k
|| (type_p->name != NAMETABLE_NIL_ID
&& mode == CHK_follow_any)
|| (!AST_REF_SET(param_p)
&& mode != CHK_follow_any)
|| (param_p->field_attrs != NULL
&& instance_has_array_attr(param_p)
&& mode != CHK_follow_ref_arr_siz)
|| ((AST_STRING_SET(type_p)
|| AST_STRING_SET(param_p))
&& type_is_string(type_p)))
return type_p;
return ptee_type_p;
}
static int def_auto_handle = 0;
static void default_to_auto_handle
(
AST_operation_n_t *op_p,
int message_id
)
{
char const *id_name;
NAMETABLE_id_to_string(op_p->name, &id_name);
message_print(message_id, id_name);
def_auto_handle++;
}
static boolean instance_is_varying_upper
(
AST_array_n_t *array_p,
AST_field_attr_n_t *fattr_p
)
{
AST_field_ref_n_t *first_p;
AST_field_ref_n_t *last_p;
AST_field_ref_n_t *length_p;
int i;
if (fattr_p == NULL)
return FALSE;
first_p = fattr_p->first_is_vec;
last_p = fattr_p->last_is_vec;
length_p = fattr_p->length_is_vec;
for (i = 1 ; i < array_p->index_count ; i++)
{
if (first_p != NULL)
{
first_p++;
if (first_p->valid)
return TRUE;
}
if (last_p != NULL)
{
last_p++;
if (last_p->valid)
return TRUE;
}
if (length_p != NULL)
{
length_p++;
if (length_p->valid)
return TRUE;
}
}
return FALSE;
}
static void fattr_switch_is
(
AST_field_attr_n_t *fattr_p,
ASTP_node_t *node_p,
AST_type_n_t *type_p
)
{
AST_type_n_t *ref_type_p;
AST_type_n_t *deref_type_p;
AST_type_n_t *sw_type_p;
NAMETABLE_id_t ref_name;
boolean is_ref_ptr;
if (fattr_p->switch_is == NULL)
return;
type_p = ASTP_chase_ptr_to_kind(type_p, AST_disc_union_k);
if (type_p == NULL)
error(NIDL_INTERNAL_ERROR, __FILE__, __LINE__);
sw_type_p = type_p->type_structure.disc_union->discrim_type;
if (sw_type_p == NULL) return;
if (node_p->fe_info->node_kind == fe_field_n_k)
{
ref_type_p = fattr_p->switch_is->ref.f_ref->type;
ref_name = fattr_p->switch_is->ref.f_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->switch_is->ref.f_ref));
}
else
{
ref_type_p = fattr_p->switch_is->ref.p_ref->type;
ref_name = fattr_p->switch_is->ref.p_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->switch_is->ref.p_ref));
}
deref_type_p = ASTP_chase_ptr_to_type(ref_type_p);
if (deref_type_p->fe_info->pointer_count > 0
&& !is_ref_ptr)
{
char const *id_name;
NAMETABLE_id_to_string(ref_name, &id_name);
CHECKER_error(fattr_p, NIDL_NEUSWPTR, id_name);
}
if (deref_type_p->kind != sw_type_p->kind)
{
char const *id_name;
char const *sw_type_name;
NAMETABLE_id_to_string(ref_name, &id_name);
NAMETABLE_id_to_string(sw_type_p->name, &sw_type_name);
if (sw_type_name == NULL) sw_type_name = "";
CHECKER_error(fattr_p, NIDL_SWDATATYPE, id_name, sw_type_name);
}
if (deref_type_p->rep_as_type != NULL)
CHECKER_error(fattr_p, NIDL_DISCRIMREPAS);
if (deref_type_p->xmit_as_type != NULL)
CHECKER_error(fattr_p, NIDL_DISCRIMXMITAS);
}
static void fattr_check_size
(
AST_field_attr_n_t *fattr_p,
ASTP_node_t *node_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p,
unsigned short dim
)
{
AST_array_n_t *array_p;
AST_array_index_n_t *index_p = NULL;
boolean str_attr_set;
if (AST_STRING_SET(type_p)
|| (node_p->fe_info->node_kind == fe_field_n_k
&& AST_STRING_SET((AST_field_n_t *)node_p))
|| (node_p->fe_info->node_kind == fe_parameter_n_k
&& AST_STRING_SET((AST_parameter_n_t *)node_p)))
str_attr_set = TRUE;
else
str_attr_set = FALSE;
if (type_p->kind == AST_array_k)
{
array_p = type_p->type_structure.array;
index_p = &array_p->index_vec[dim];
}
else
array_p = NULL;
if (fattr_p->max_is_vec != NULL
&& fattr_p->max_is_vec[dim].valid
&& fattr_p->size_is_vec != NULL
&& fattr_p->size_is_vec[dim].valid)
CHECKER_error(fattr_p, NIDL_MAXSIZECONF);
if (fattr_p->min_is_vec != NULL
&& fattr_p->min_is_vec[dim].valid
&& fattr_p->min_is_vec[dim].constant == false
&& fattr_p->size_is_vec != NULL
&& fattr_p->size_is_vec[dim].valid
&& fattr_p->size_is_vec[dim].constant == true)
CHECKER_error(fattr_p, NIDL_CONSTREQ);
if (fattr_p->last_is_vec != NULL
&& fattr_p->last_is_vec[dim].valid
&& fattr_p->length_is_vec != NULL
&& fattr_p->length_is_vec[dim].valid)
CHECKER_error(fattr_p, NIDL_LASTLENCONF);
if (fattr_p->first_is_vec != NULL
&& fattr_p->first_is_vec[dim].valid
&& fattr_p->first_is_vec[dim].constant == false
&& fattr_p->length_is_vec != NULL
&& fattr_p->length_is_vec[dim].valid
&& fattr_p->length_is_vec[dim].constant == true)
CHECKER_error(fattr_p, NIDL_CONSTREQ);
if (type_p->kind == AST_pointer_k)
{
AST_type_n_t *ref_type_p;
ref_type_p = ASTP_chase_ptr_to_type(type_p);
if (ref_type_p->kind == AST_array_k)
return;
}
else if (fattr_p->range != NULL && !type_is_rangeable(type_p))
{
CHECKER_error(fattr_p, NIDL_RANGEATTR);
}
if (array_p != NULL
&& !AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL
&& !AST_FIXED_UPPER_SET(index_p)
&& (fattr_p->max_is_vec == NULL
|| !fattr_p->max_is_vec[dim].valid)
&& (fattr_p->size_is_vec == NULL
|| !fattr_p->size_is_vec[dim].valid))
CHECKER_error(fattr_p, NIDL_MAXSIZEATTR);
if (array_p == NULL
&& !str_attr_set
&& (fattr_p->first_is_vec != NULL
|| fattr_p->last_is_vec != NULL
|| fattr_p->length_is_vec != NULL
|| fattr_p->min_is_vec != NULL)
&& fattr_p->max_is_vec == NULL
&& fattr_p->size_is_vec == NULL)
CHECKER_error(fattr_p, NIDL_MAXSIZEATTR);
if (array_p != NULL
&& !AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL
&& !AST_FIXED_LOWER_SET(index_p)
&& (fattr_p->min_is_vec == NULL
|| !fattr_p->min_is_vec[dim].valid))
CHECKER_error(fattr_p, NIDL_MINATTREQ);
if (array_p != NULL && fattr_p->range != NULL)
CHECKER_error(fattr_p, NIDL_RANGEATTR);
}
static void fattr_first_is
(
AST_field_attr_n_t *fattr_p,
ASTP_node_t *node_p,
unsigned short dim
)
{
AST_type_n_t *ref_type_p;
AST_type_n_t *deref_type_p = NULL;
NAMETABLE_id_t ref_name = 0;
boolean is_ref_ptr = false;
if (fattr_p->first_is_vec != NULL
&& fattr_p->first_is_vec[dim].valid)
{
if (fattr_p->first_is_vec[dim].constant)
return;
if (node_p->fe_info->node_kind == fe_field_n_k)
{
ref_type_p = fattr_p->first_is_vec[dim].ref.f_ref->type;
ref_name = fattr_p->first_is_vec[dim].ref.f_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->first_is_vec[dim].ref.f_ref));
}
else
{
ref_type_p = fattr_p->first_is_vec[dim].ref.p_ref->type;
ref_name = fattr_p->first_is_vec[dim].ref.p_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->first_is_vec[dim].ref.p_ref));
}
deref_type_p = ASTP_chase_ptr_to_type(ref_type_p);
assert(deref_type_p != NULL);
if (!type_is_index(deref_type_p)
|| deref_type_p->fe_info->pointer_count
!= fattr_p->first_is_vec[dim].fe_info->pointer_count)
CHECKER_error(fattr_p, NIDL_FIRSTYPEINT);
if (deref_type_p->rep_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARREPAS);
if (deref_type_p->xmit_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARXMITAS);
if (deref_type_p->fe_info->pointer_count > 0
&& !is_ref_ptr)
{
char const *id_name;
NAMETABLE_id_to_string(ref_name, &id_name);
CHECKER_error(fattr_p, NIDL_SIZEPRMPTR, id_name);
}
}
}
static void fattr_last_is
(
AST_field_attr_n_t *fattr_p,
ASTP_node_t *node_p,
unsigned short dim
)
{
AST_type_n_t *ref_type_p;
AST_type_n_t *deref_type_p = NULL;
NAMETABLE_id_t ref_name = 0;
boolean is_ref_ptr = false;
if (fattr_p->last_is_vec != NULL
&& fattr_p->last_is_vec[dim].valid)
{
if (fattr_p->last_is_vec[dim].constant)
return;
if (node_p->fe_info->node_kind == fe_field_n_k)
{
ref_type_p = fattr_p->last_is_vec[dim].ref.f_ref->type;
ref_name = fattr_p->last_is_vec[dim].ref.f_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->last_is_vec[dim].ref.f_ref));
}
else
{
ref_type_p = fattr_p->last_is_vec[dim].ref.p_ref->type;
ref_name = fattr_p->last_is_vec[dim].ref.p_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->last_is_vec[dim].ref.p_ref));
}
deref_type_p = ASTP_chase_ptr_to_type(ref_type_p);
assert(deref_type_p != NULL);
if (!type_is_index(deref_type_p)
|| deref_type_p->fe_info->pointer_count
!= fattr_p->last_is_vec[dim].fe_info->pointer_count)
CHECKER_error(fattr_p, NIDL_LASTYPEINT);
if (deref_type_p->rep_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARREPAS);
if (deref_type_p->xmit_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARXMITAS);
if (deref_type_p->fe_info->pointer_count > 0
&& !is_ref_ptr)
{
char const *id_name;
NAMETABLE_id_to_string(ref_name, &id_name);
CHECKER_error(fattr_p, NIDL_SIZEPRMPTR, id_name);
}
}
}
static void fattr_length_is
(
AST_field_attr_n_t *fattr_p,
ASTP_node_t *node_p,
unsigned short dim
)
{
AST_type_n_t *ref_type_p;
AST_type_n_t *deref_type_p = NULL;
NAMETABLE_id_t ref_name = 0;
boolean is_ref_ptr = false;
if (fattr_p->length_is_vec != NULL
&& fattr_p->length_is_vec[dim].valid)
{
if (fattr_p->length_is_vec[dim].constant)
return;
if (node_p->fe_info->node_kind == fe_field_n_k)
{
ref_type_p = fattr_p->length_is_vec[dim].ref.f_ref->type;
ref_name = fattr_p->length_is_vec[dim].ref.f_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->length_is_vec[dim].ref.f_ref));
}
else
{
ref_type_p = fattr_p->length_is_vec[dim].ref.p_ref->type;
ref_name = fattr_p->length_is_vec[dim].ref.p_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->length_is_vec[dim].ref.p_ref));
}
deref_type_p = ASTP_chase_ptr_to_type(ref_type_p);
assert(deref_type_p != NULL);
if (!type_is_index(deref_type_p)
|| deref_type_p->fe_info->pointer_count
!= fattr_p->length_is_vec[dim].fe_info->pointer_count)
CHECKER_error(fattr_p, NIDL_LENTYPEINT);
if (deref_type_p->rep_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARREPAS);
if (deref_type_p->xmit_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARXMITAS);
if (deref_type_p->fe_info->pointer_count > 0
&& !is_ref_ptr)
{
char const *id_name;
NAMETABLE_id_to_string(ref_name, &id_name);
CHECKER_error(fattr_p, NIDL_SIZEPRMPTR, id_name);
}
}
}
static void fattr_min_is
(
AST_field_attr_n_t *fattr_p,
ASTP_node_t *node_p,
AST_type_n_t *type_p,
unsigned short dim
)
{
AST_array_n_t *array_p;
AST_array_index_n_t *index_p = NULL;
AST_type_n_t *ref_type_p;
AST_type_n_t *deref_type_p = NULL;
NAMETABLE_id_t ref_name = 0;
boolean is_ref_ptr = false;
if (type_p->kind == AST_array_k)
{
array_p = type_p->type_structure.array;
index_p = &array_p->index_vec[dim];
}
else
array_p = NULL;
if (fattr_p->min_is_vec != NULL
&& fattr_p->min_is_vec[dim].valid
&& fattr_p->min_is_vec[dim].constant == false)
{
if (node_p->fe_info->node_kind == fe_field_n_k)
{
ref_type_p = fattr_p->min_is_vec[dim].ref.f_ref->type;
ref_name = fattr_p->min_is_vec[dim].ref.f_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->min_is_vec[dim].ref.f_ref));
}
else
{
ref_type_p = fattr_p->min_is_vec[dim].ref.p_ref->type;
ref_name = fattr_p->min_is_vec[dim].ref.p_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->min_is_vec[dim].ref.p_ref));
}
deref_type_p = ASTP_chase_ptr_to_type(ref_type_p);
}
if (type_p->kind == AST_pointer_k
&& fattr_p->min_is_vec != NULL
&& (*(int *)cmd_val[opt_standard] <= opt_standard_dce_1_0))
CHECKER_warning(fattr_p, NIDL_NOPORTNZLB, OPT_STD_EXTENDED);
if (array_p != NULL
&& fattr_p->min_is_vec != NULL
&& (!type_is_array(type_p)
|| (type_is_array(type_p)
&& fattr_p->min_is_vec[dim].valid
&& AST_FIXED_LOWER_SET(index_p))))
CHECKER_error(fattr_p, NIDL_MINCFMTYPE, dim+1);
if (fattr_p->min_is_vec != NULL
&& fattr_p->min_is_vec[dim].valid
&& fattr_p->min_is_vec[dim].constant)
return;
if (fattr_p->min_is_vec != NULL
&& fattr_p->min_is_vec[dim].valid) {
assert(deref_type_p != NULL);
if (!type_is_index(deref_type_p)
|| deref_type_p->fe_info->pointer_count
!= fattr_p->min_is_vec[dim].fe_info->pointer_count)
CHECKER_error(fattr_p, NIDL_MINTYPEINT);
if (deref_type_p->rep_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARREPAS);
if (deref_type_p->xmit_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARXMITAS);
if (deref_type_p->fe_info->pointer_count > 0
&& !is_ref_ptr)
{
char const *id_name;
NAMETABLE_id_to_string(ref_name, &id_name);
CHECKER_error(fattr_p, NIDL_SIZEPRMPTR, id_name);
}
}
}
static void fattr_max_is
(
AST_field_attr_n_t *fattr_p,
ASTP_node_t *node_p,
AST_type_n_t *type_p,
unsigned short dim
)
{
AST_array_n_t *array_p;
AST_array_index_n_t *index_p = NULL;
AST_type_n_t *ref_type_p;
AST_type_n_t *deref_type_p = NULL;
NAMETABLE_id_t ref_name = 0;
boolean is_ref_ptr = false;
if (type_p->kind == AST_array_k)
{
array_p = type_p->type_structure.array;
index_p = &array_p->index_vec[dim];
}
else
array_p = NULL;
if (fattr_p->max_is_vec != NULL
&& fattr_p->max_is_vec[dim].valid
&& fattr_p->max_is_vec[dim].constant == false)
{
if (node_p->fe_info->node_kind == fe_field_n_k)
{
ref_type_p = fattr_p->max_is_vec[dim].ref.f_ref->type;
ref_name = fattr_p->max_is_vec[dim].ref.f_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->max_is_vec[dim].ref.f_ref));
}
else
{
ref_type_p = fattr_p->max_is_vec[dim].ref.p_ref->type;
ref_name = fattr_p->max_is_vec[dim].ref.p_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->max_is_vec[dim].ref.p_ref));
}
deref_type_p = ASTP_chase_ptr_to_type(ref_type_p);
}
if (array_p != NULL
&& fattr_p->max_is_vec != NULL
&& (!type_is_array(type_p)
|| (type_is_array(type_p)
&& fattr_p->max_is_vec[dim].valid
&& AST_FIXED_UPPER_SET(index_p))))
CHECKER_error(fattr_p, NIDL_MAXCFMTYPE, dim+1);
if (fattr_p->max_is_vec != NULL
&& fattr_p->max_is_vec[dim].valid
&& fattr_p->max_is_vec[dim].constant == true)
return;
if (fattr_p->max_is_vec != NULL
&& fattr_p->max_is_vec[dim].valid) {
assert(deref_type_p != NULL);
if (!type_is_index(deref_type_p)
|| deref_type_p->fe_info->pointer_count
!= fattr_p->max_is_vec[dim].fe_info->pointer_count)
CHECKER_error(fattr_p, NIDL_MAXTYPEINT);
if (deref_type_p->rep_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARREPAS);
if (deref_type_p->xmit_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARXMITAS);
if (deref_type_p->fe_info->pointer_count > 0
&& !is_ref_ptr)
{
char const *id_name;
NAMETABLE_id_to_string(ref_name, &id_name);
CHECKER_error(fattr_p, NIDL_SIZEPRMPTR, id_name);
}
}
}
static void fattr_size_is
(
AST_field_attr_n_t *fattr_p,
ASTP_node_t *node_p,
AST_type_n_t *type_p,
unsigned short dim
)
{
AST_array_n_t *array_p;
AST_array_index_n_t *index_p = NULL;
AST_type_n_t *ref_type_p;
AST_type_n_t *deref_type_p = NULL;
NAMETABLE_id_t ref_name = 0;
boolean is_ref_ptr = false;
if (type_p->kind == AST_array_k)
{
array_p = type_p->type_structure.array;
index_p = &array_p->index_vec[dim];
}
else
array_p = NULL;
if (fattr_p->size_is_vec != NULL
&& fattr_p->size_is_vec[dim].valid
&& fattr_p->size_is_vec[dim].constant == false)
{
if (node_p->fe_info->node_kind == fe_field_n_k)
{
ref_type_p = fattr_p->size_is_vec[dim].ref.f_ref->type;
ref_name = fattr_p->size_is_vec[dim].ref.f_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->size_is_vec[dim].ref.f_ref));
}
else
{
ref_type_p = fattr_p->size_is_vec[dim].ref.p_ref->type;
ref_name = fattr_p->size_is_vec[dim].ref.p_ref->name;
is_ref_ptr = (AST_REF_SET(fattr_p->size_is_vec[dim].ref.p_ref));
}
deref_type_p = ASTP_chase_ptr_to_type(ref_type_p);
}
if (array_p != NULL
&& fattr_p->size_is_vec != NULL
&& (!type_is_array(type_p)
|| (type_is_array(type_p)
&& fattr_p->size_is_vec[dim].valid
&& AST_FIXED_UPPER_SET(index_p))))
CHECKER_error(fattr_p, NIDL_SIZECFMTYPE, dim+1);
if (fattr_p->size_is_vec != NULL
&& fattr_p->size_is_vec[dim].valid
&& fattr_p->size_is_vec[dim].constant == true)
return;
if (fattr_p->size_is_vec != NULL
&& fattr_p->size_is_vec[dim].valid) {
assert(deref_type_p != NULL);
if (!type_is_index(deref_type_p)
|| deref_type_p->fe_info->pointer_count
!= fattr_p->size_is_vec[dim].fe_info->pointer_count)
CHECKER_error(fattr_p, NIDL_SIZETYPEINT);
if (deref_type_p->rep_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARREPAS);
if (deref_type_p->xmit_as_type != NULL)
CHECKER_error(fattr_p, NIDL_SIZEVARXMITAS);
if (deref_type_p->fe_info->pointer_count > 0
&& !is_ref_ptr)
{
char const *id_name;
NAMETABLE_id_to_string(ref_name, &id_name);
CHECKER_error(fattr_p, NIDL_SIZEPRMPTR, id_name);
}
}
}
static void fattr_param_conformant
(
AST_field_attr_n_t *fattr_p,
AST_parameter_n_t *param_p,
AST_interface_n_t *int_p,
unsigned short dim
)
{
if (!AST_LOCAL_SET(int_p)
&& param_p->type->xmit_as_type == NULL
&& fattr_p->min_is_vec != NULL
&& fattr_p->min_is_vec[dim].valid
&& fattr_p->min_is_vec[dim].constant == false
&& AST_IN_SET(param_p)
&& !AST_IN_SET(fattr_p->min_is_vec[dim].ref.p_ref))
CHECKER_error(fattr_p, NIDL_MININATTR);
if (!AST_LOCAL_SET(int_p)
&& param_p->type->xmit_as_type == NULL
&& fattr_p->max_is_vec != NULL
&& fattr_p->max_is_vec[dim].valid
&& fattr_p->max_is_vec[dim].constant == false
&& AST_IN_SET(param_p)
&& !AST_IN_SET(fattr_p->max_is_vec[dim].ref.p_ref))
CHECKER_error(fattr_p, NIDL_MAXINATTR);
if (!AST_LOCAL_SET(int_p)
&& param_p->type->xmit_as_type == NULL
&& fattr_p->size_is_vec != NULL
&& fattr_p->size_is_vec[dim].valid
&& fattr_p->size_is_vec[dim].constant == false
&& AST_IN_SET(param_p)
&& !AST_IN_SET(fattr_p->size_is_vec[dim].ref.p_ref))
CHECKER_error(fattr_p, NIDL_SIZEINATTR);
}
static void fattr_param_varying
(
AST_field_attr_n_t *fattr_p,
AST_parameter_n_t *param_p,
AST_interface_n_t *int_p,
unsigned short dim
)
{
if (!AST_LOCAL_SET(int_p)
&& param_p->type->xmit_as_type == NULL
&& fattr_p->first_is_vec != NULL
&& fattr_p->first_is_vec[dim].valid
&& fattr_p->first_is_vec[dim].constant == false
&& AST_IN_SET(param_p)
&& !AST_IN_SET(fattr_p->first_is_vec[dim].ref.p_ref))
CHECKER_error(fattr_p, NIDL_FIRSTINATTR);
if (!AST_LOCAL_SET(int_p)
&& param_p->type->xmit_as_type == NULL
&& fattr_p->last_is_vec != NULL
&& fattr_p->last_is_vec[dim].valid
&& fattr_p->last_is_vec[dim].constant == false
&& AST_IN_SET(param_p)
&& !AST_IN_SET(fattr_p->last_is_vec[dim].ref.p_ref))
CHECKER_error(fattr_p, NIDL_LASTINATTR);
if (!AST_LOCAL_SET(int_p)
&& param_p->type->xmit_as_type == NULL
&& fattr_p->length_is_vec != NULL
&& fattr_p->length_is_vec[dim].valid
&& fattr_p->length_is_vec[dim].constant == false
&& AST_IN_SET(param_p)
&& !AST_IN_SET(fattr_p->length_is_vec[dim].ref.p_ref))
CHECKER_error(fattr_p, NIDL_LENINATTR);
}
static void fattr_param_check
(
AST_field_attr_n_t *fattr_p,
AST_parameter_n_t *param_p,
AST_interface_n_t *int_p
)
{
unsigned short dim;
unsigned short max_dim;
AST_type_n_t *type_p;
type_p = param_p->type;
if (type_p->kind == AST_array_k)
max_dim = type_p->type_structure.array->index_count;
else
max_dim = 1;
for (dim = 0 ; dim < max_dim ; dim++)
{
fattr_param_conformant(fattr_p, param_p, int_p, dim);
fattr_param_varying(fattr_p, param_p, int_p, dim);
}
}
static void fattr_check
(
AST_field_attr_n_t *fattr_p,
ASTP_node_t *node_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
unsigned short dim;
unsigned short max_dim;
if (type_p->kind == AST_array_k)
max_dim = type_p->type_structure.array->index_count;
else
max_dim = 1;
if ( ((fattr_p->max_is_vec != NULL) && (fattr_p->length_is_vec != NULL))
|| ((fattr_p->size_is_vec != NULL) && (fattr_p->last_is_vec != NULL)))
CHECKER_warning(fattr_p, NIDL_MIXEDARRATTR);
fattr_switch_is(fattr_p, node_p, type_p);
for (dim = 0 ; dim < max_dim ; dim++)
{
fattr_check_size(fattr_p, node_p, type_p, int_p, dim);
fattr_first_is(fattr_p, node_p, dim);
fattr_last_is(fattr_p, node_p, dim);
fattr_length_is(fattr_p, node_p, dim);
fattr_min_is(fattr_p, node_p, type_p, dim);
fattr_max_is(fattr_p, node_p, type_p, dim);
fattr_size_is(fattr_p, node_p, type_p, dim);
}
}
static void index_const_type
(
AST_array_index_n_t *index_p
)
{
if ((AST_FIXED_LOWER_SET(index_p)
&& !const_is_integer(index_p->lower_bound))
||
(AST_FIXED_UPPER_SET(index_p)
&& !const_is_integer(index_p->upper_bound)))
CHECKER_error(index_p, NIDL_INVARRIND);
}
static void index_bounds
(
AST_array_index_n_t *index_p
)
{
if (AST_FIXED_LOWER_SET(index_p)
&& AST_FIXED_UPPER_SET(index_p)
&& index_p->lower_bound->value.int_val
> index_p->upper_bound->value.int_val)
CHECKER_error(index_p, NIDL_LBLESSUB);
if ( (!AST_FIXED_LOWER_SET(index_p)
|| index_p->lower_bound->value.int_val != 0)
&& (*(int *)cmd_val[opt_standard] <= opt_standard_dce_1_0) )
CHECKER_warning(index_p, NIDL_NOPORTNZLB, OPT_STD_EXTENDED);
}
static void index_check
(
AST_array_index_n_t *index_p
)
{
index_const_type(index_p);
index_bounds(index_p);
}
static void array_element_type
(
ASTP_node_t *node_p,
AST_type_n_t *type_p,
AST_type_n_t *arr_type_p,
AST_interface_n_t *int_p,
boolean arrayified
)
{
AST_type_n_t *etype_p;
if (type_is_anonymous(type_p))
type_check(type_p, (ASTP_node_t *)node_p, int_p);
etype_p = type_p;
type_p = type_xmit_type(type_p);
if (AST_CONFORMANT_SET(type_p)
&& !(etype_p != type_p && AST_STRING_SET(type_p))
&& !(etype_p != type_p && type_p->kind == AST_structure_k) )
CHECKER_error(node_p, NIDL_ARRELEMCFMT);
if (type_p->kind == AST_pipe_k)
CHECKER_error(node_p, NIDL_ARRELEMPIPE);
if (AST_CONTEXT_RD_SET(type_p))
CHECKER_error(node_p, NIDL_ARRELEMCTX);
if (!AST_LOCAL_SET(int_p)
&& type_is_function(type_p)
&& (AST_CONFORMANT_SET(arr_type_p) || arrayified))
CHECKER_error(node_p, NIDL_FPCFMTARR);
if (!AST_LOCAL_SET(int_p)
&& type_p->kind == AST_handle_k)
#if 0
&& type_p->xmit_as_type == NULL)
#endif
CHECKER_error(node_p, NIDL_HANARRELEM);
if (type_p->kind == AST_void_k)
CHECKER_error(node_p, NIDL_VOIDOPPTR);
if (!AST_LOCAL_SET(int_p)
#if 0
&& type_p->xmit_as_type == NULL
#endif
&& type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind == AST_void_k
&& !AST_CONTEXT_RD_SET(type_p)
)
{
CHECKER_error(node_p, NIDL_PTRVOIDCTX);
}
if (AST_IGNORE_SET(type_p))
CHECKER_error(node_p, NIDL_IGNARRELEM);
}
static void array_check
(
ASTP_node_t *node_p,
AST_type_n_t *arr_type_p,
ASTP_node_t *parent_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p,
boolean arrayified
)
{
unsigned short dim;
if (arr_type_p->xmit_as_type != NULL
&& (AST_CONFORMANT_SET(arr_type_p)
|| (parent_p->fe_info->node_kind == fe_parameter_n_k
&& ((AST_parameter_n_t *)parent_p)->field_attrs != NULL)
|| (parent_p->fe_info->node_kind == fe_field_n_k
&& ((AST_field_n_t *)parent_p)->field_attrs != NULL)))
CHECKER_error(parent_p, NIDL_ARRXMITOPEN);
array_element_type(node_p, type_p, arr_type_p, int_p, arrayified);
if (type_p->kind == AST_disc_union_k
&& type_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID)
CHECKER_error(arr_type_p, NIDL_NEUARRAY);
if (type_p->kind == AST_interface_k) {
char const * id_name;
NAMETABLE_id_to_string(type_p->name, &id_name);
CHECKER_error(arr_type_p, NIDL_INTREFNOTALO, id_name);
}
if (node_p->fe_info->node_kind == fe_array_n_k)
{
AST_array_n_t *array_p;
array_p = (AST_array_n_t *)node_p;
for (dim = 0
; dim < array_p->index_count
; dim++)
index_check(&array_p->index_vec[dim]);
}
}
static void param_type
(
AST_parameter_n_t *param_p,
AST_type_n_t *top_type_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
#if 0
AST_type_n_t *btype_p;
btype_p = ASTP_chase_ptr_to_kind(top_type_p, AST_disc_union_k);
if (btype_p != NULL
&& btype_p->kind == AST_disc_union_k
&& btype_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID
&& btype_p->fe_info->pointer_count > 1)
CHECKER_error(top_type_p, NIDL_PTRNEUNION);
#endif
if (type_is_anonymous(type_p))
type_check(type_p, (ASTP_node_t *)param_p, int_p);
type_p = type_xmit_type(type_p);
if (type_p->kind == AST_void_k
&& param_p != param_p->uplink->result)
CHECKER_error(param_p, NIDL_VOIDOPPTR);
if (!AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL
&& type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind == AST_void_k
&& !AST_CONTEXT_RD_SET(type_p)
&& !AST_CONTEXT_SET(param_p)
&& !AST_LOCAL_SET(param_p->uplink)
)
CHECKER_error(param_p, NIDL_PTRVOIDCTX);
if (top_type_p->xmit_as_type != NULL
&&
(AST_STRING_SET(param_p)
|| AST_STRING0_SET(param_p)
|| AST_UNIQUE_SET(param_p)
|| AST_SMALL_SET(param_p)
|| AST_CONTEXT_SET(param_p)
))
CHECKER_error(param_p, NIDL_XMITTYPEATTRS);
if (FE_TEST(param_p->fe_info->flags, FE_HAS_V1_ATTR)
&& FE_TEST(param_p->fe_info->flags, FE_HAS_V2_ATTR)
&& ! ( FE_TEST(type_p->fe_info->flags, FE_HAS_V1_ATTR)
&& FE_TEST(type_p->fe_info->flags, FE_HAS_V2_ATTR) ))
CHECKER_warning(param_p, NIDL_INCOMPATV1);
if (type_p->kind == AST_array_k
&& param_p == param_p->uplink->result)
CHECKER_error(param_p, NIDL_ARRFUNRES);
}
static void param_size
(
AST_parameter_n_t *param_p,
AST_type_n_t *top_type_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
AST_field_attr_n_t *fattr_p;
fattr_p = param_p->field_attrs;
if (!AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL
&& fattr_p == NULL
&& type_is_array(type_p)
&& (AST_CONFORMANT_SET(type_p)
|| AST_VARYING_SET(param_p))
&& !AST_STRING_SET(type_p)
&& !AST_STRING_SET(param_p))
{
char const *id_name;
NAMETABLE_id_to_string(param_p->name, &id_name);
CHECKER_error(param_p, NIDL_ARRSIZEINFO, id_name);
}
if (!AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL
&& fattr_p == NULL
&& ( (type_p->kind == AST_array_k
&& AST_CONFORMANT_SET(type_p))
|| (type_p->kind == AST_pointer_k
&& param_p->uplink->result != param_p
&& !AST_PTR_SET(type_p) && !AST_UNIQUE_SET(type_p)) )
&& (AST_STRING_SET(type_p) || AST_STRING_SET(param_p))
&& !AST_IN_SET(param_p))
{
char const *id_name;
NAMETABLE_id_to_string(param_p->name, &id_name);
CHECKER_error(param_p, NIDL_ARRSIZEINFO, id_name);
}
if (!AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL
&& AST_STRING_SET(param_p)
&& fattr_p != NULL
&& (fattr_p->first_is_vec != NULL
|| fattr_p->last_is_vec != NULL
|| fattr_p->length_is_vec != NULL))
CHECKER_error(param_p, NIDL_STRVARY);
if (type_p->xmit_as_type != NULL
&& fattr_p != NULL)
CHECKER_error(param_p, NIDL_ARRXMITOPEN);
if (top_type_p->kind == AST_pointer_k)
{
AST_type_n_t *ref_type_p;
ref_type_p = ASTP_chase_ptr_to_type(top_type_p);
if (ref_type_p->kind == AST_array_k
&& !AST_CONFORMANT_SET(ref_type_p)
&& fattr_p != NULL
&& (fattr_p->min_is_vec != NULL
|| fattr_p->max_is_vec != NULL
|| fattr_p->size_is_vec != NULL))
CHECKER_error(param_p, NIDL_ARRSYNTAX);
if (ref_type_p->kind == AST_array_k
&& AST_CONFORMANT_SET(ref_type_p)
&& (!AST_STRING_SET(ref_type_p)
|| (fattr_p != NULL
&& (fattr_p->min_is_vec != NULL
|| fattr_p->max_is_vec != NULL
|| fattr_p->size_is_vec != NULL))))
{
CHECKER_error(param_p, NIDL_PTRCFMTARR);
return;
}
if (ref_type_p->kind == AST_array_k
&& fattr_p != NULL
&& (fattr_p->first_is_vec != NULL
|| fattr_p->last_is_vec != NULL
|| fattr_p->length_is_vec != NULL))
{
CHECKER_error(param_p, NIDL_PTRVARYARR);
return;
}
}
if (!AST_LOCAL_SET(int_p)
&& param_p->type->xmit_as_type == NULL
&& !AST_IN_SET(param_p)
&& FE_TEST(param_p->fe_info->flags, FE_HAS_CFMT_ARR))
CHECKER_error(param_p, NIDL_OUTCFMTARR);
}
static void param_struct
(
AST_parameter_n_t *param_p,
AST_type_n_t *top_type_p,
AST_type_n_t *type_p
)
{
type_p = type_xmit_type(type_p);
if (type_p->kind != AST_structure_k)
return;
if (!AST_OUT_SET(param_p)
&& top_type_p->kind != AST_pointer_k
&& AST_CONFORMANT_SET(type_p))
CHECKER_error(param_p, NIDL_CFMTARRREF);
}
static void param_pipe
(
AST_parameter_n_t *param_p,
AST_type_n_t *top_type_p ATTRIBUTE_UNUSED,
AST_type_n_t *type_p
)
{
type_p = type_xmit_type(type_p);
if (type_p->kind == AST_pipe_k
&& AST_PTR_SET(param_p))
CHECKER_error(param_p, NIDL_PTRPIPE);
if (param_p == param_p->uplink->result
&& type_p->kind == AST_pipe_k)
CHECKER_error(param_p, NIDL_OPRESPIPE);
}
static void param_in_line
(
AST_parameter_n_t *param_p,
AST_type_n_t *type_p
)
{
if (AST_IN_LINE_SET(param_p)
&& AST_OUT_OF_LINE_SET(param_p))
CHECKER_acf_error(param_p, NIDL_PRMLINEATTR);
if ((AST_IN_LINE_SET(param_p) || AST_OUT_OF_LINE_SET(param_p))
&& type_is_scalar(type_p))
{
char const *file_name;
char const *type_name;
STRTAB_str_to_string(type_p->fe_info->file, &file_name);
NAMETABLE_id_to_string(type_p->name, &type_name);
CHECKER_acf_warning(param_p, NIDL_LINENONSCAL);
CHECKER_acf_warning(param_p, NIDL_NAMEDECLAT, type_name, file_name,
type_p->fe_info->source_line);
}
}
static void param_string
(
AST_parameter_n_t *param_p,
AST_type_n_t *type_p
)
{
if (AST_STRING0_SET(param_p)
&& !type_is_v1_string(type_p))
CHECKER_error(param_p, NIDL_STRV1FIXED);
if ((AST_STRING0_SET(param_p) || AST_STRING0_SET(type_p))
&& !(AST_SMALL_SET(param_p) || AST_SMALL_SET(type_p)))
CHECKER_error(param_p, NIDL_STRV1ARRAY);
if ((AST_STRING_SET(param_p) && AST_SMALL_SET(param_p))
|| (AST_STRING_SET(param_p) && AST_SMALL_SET(type_p))
|| (AST_STRING_SET(type_p) && AST_SMALL_SET(param_p)))
CHECKER_error(param_p, NIDL_STRARRAYV1);
if ( (AST_STRING_SET(param_p) || AST_STRING_SET(type_p))
&& (AST_STRING0_SET(param_p) || AST_STRING0_SET(type_p)) )
{
ASTP_attr_flag_t attr1 = ASTP_STRING;
ASTP_attr_flag_t attr2 = ASTP_STRING0;
CHECKER_error(param_p, NIDL_CONFLICTATTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)),
KEYWORDS_lookup_text(AST_attribute_to_token(&attr2)));
}
if (type_p->kind == AST_pointer_k)
{
AST_type_n_t *ref_type_p;
ref_type_p = ASTP_chase_ptr_to_type(type_p);
if (ref_type_p->kind == AST_array_k
&& (param_p->field_attrs != NULL
|| (AST_CONFORMANT_SET(ref_type_p)
&& !AST_STRING_SET(ref_type_p))))
return;
}
if (AST_STRING_SET(param_p)
&& !type_is_string(param_p->type))
CHECKER_error(param_p, NIDL_STRCHARBYTE);
}
static void param_pointer
(
AST_parameter_n_t *param_p,
AST_type_n_t *top_type_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
boolean pointer_attr_valid = FALSE;
if (AST_OUT_SET(param_p)
&& !AST_IN_SET(param_p)
&& AST_PTR_SET(param_p)
&& param_p->uplink->result != param_p)
CHECKER_error(param_p, NIDL_OUTPTRPRM);
if (AST_OUT_SET(param_p)
&& !AST_IN_SET(param_p)
&& AST_UNIQUE_SET(param_p)
&& param_p->uplink->result != param_p)
CHECKER_error(param_p, NIDL_OUTUNIQPRM);
if (param_p->uplink->result == param_p
&& AST_REF_SET(param_p))
CHECKER_error(param_p, NIDL_REFFUNRES);
if (param_p->uplink->result == param_p
&& AST_UNIQUE_SET(param_p))
CHECKER_error(param_p, NIDL_UNIQFUNRES);
if (top_type_p->kind == AST_array_k
|| (top_type_p->kind == AST_pointer_k
&& top_type_p->type_structure.pointer->pointee_type->kind
!= AST_void_k))
pointer_attr_valid = TRUE;
if (AST_REF_SET(param_p) && !pointer_attr_valid)
CHECKER_error(param_p, NIDL_REFATTRPTR);
if (AST_UNIQUE_SET(param_p) && !pointer_attr_valid)
CHECKER_error(param_p, NIDL_UNIQATTRPTR);
if (AST_PTR_SET(param_p) && !pointer_attr_valid)
CHECKER_error(param_p, NIDL_PTRATTRPTR);
if (AST_UNIQUE_SET(param_p)
&& (*(int *)cmd_val[opt_standard] <= opt_standard_dce_1_0))
CHECKER_warning(param_p, NIDL_NOPORTUNIQUE, OPT_STD_EXTENDED);
#if 0
if (top_type_p->kind == AST_pointer_k && type_p->kind == AST_interface_k
&& AST_REF_SET(param_p))
CHECKER_warning(param_p, NIDL_PTRATTBIGN);
if (type_p->kind == AST_pointer_k && type_p->type_structure.pointer->pointee_type->kind == AST_interface_k
&& (AST_UNIQUE_SET(param_p) || AST_PTR_SET(param_p)))
CHECKER_warning(param_p, NIDL_PTRATTBIGN);
#endif
if (type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind != AST_array_k
#if 0
&& (param_p->field_attrs != NULL
#endif
&& (instance_has_array_attr(param_p)
|| AST_STRING_SET(type_p)
|| AST_STRING_SET(param_p)))
{
array_check((ASTP_node_t *)type_p->type_structure.pointer,
type_p,
(ASTP_node_t *)param_p,
type_p->type_structure.pointer->pointee_type,
int_p,
true);
if (AST_OUT_SET(param_p)
&& AST_IN_SET(param_p)
&& AST_UNIQUE_SET(param_p)
&& param_p->uplink->result != param_p)
CHECKER_error(param_p, NIDL_OUTUNIQPRM);
}
}
static void param_small
(
AST_parameter_n_t *param_p,
AST_type_n_t *top_type_p,
AST_type_n_t *type_p
)
{
AST_array_n_t *array_p;
AST_field_attr_n_t *fattr_p;
if (AST_SMALL_SET(param_p)
&& (type_p->kind == AST_pointer_k
|| top_type_p->kind == AST_pointer_k))
CHECKER_error(param_p, NIDL_SMALLARRSYN);
if (!type_is_array_np(type_p))
return;
fattr_p = param_p->field_attrs;
array_p = type_p->type_structure.array;
if (AST_SMALL_SET(param_p)
&& ((AST_CONFORMANT_SET(type_p)
&& array_is_conformant_upper(array_p))
||
(AST_VARYING_SET(param_p)
&& instance_is_varying_upper(array_p, param_p->field_attrs))))
CHECKER_error(param_p, NIDL_SMALLMULTID);
if (AST_SMALL_SET(param_p)
&& array_is_large(array_p))
CHECKER_error(param_p, NIDL_SMALLINV);
if ((AST_SMALL_SET(type_p) || AST_SMALL_SET(param_p))
&& AST_CONFORMANT_SET(type_p)
&& !AST_VARYING_SET(param_p))
CHECKER_error(param_p, NIDL_SMALLCFMT);
if ((AST_SMALL_SET(type_p) || AST_SMALL_SET(param_p))
&& fattr_p != NULL
&& (fattr_p->min_is_vec != NULL
|| fattr_p->first_is_vec != NULL))
CHECKER_error(param_p, NIDL_SMALLMINFIRST);
}
static void param_context
(
AST_parameter_n_t *param_p,
AST_type_n_t *top_type_p,
AST_type_n_t *type_p
)
{
AST_type_n_t *deref_type_p;
boolean type_is_pointer;
deref_type_p = param_follow_ref_ptr(param_p, CHK_follow_any);
if (param_p->uplink->result == param_p
&& type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind != AST_void_k)
deref_type_p = type_p->type_structure.pointer->pointee_type;
if (AST_CONTEXT_SET(param_p)
&& !AST_CONTEXT_RD_SET(type_p)
&& (deref_type_p->kind != AST_pointer_k
|| (deref_type_p->kind == AST_pointer_k
&& deref_type_p->type_structure.pointer->pointee_type->kind
!= AST_void_k)))
CHECKER_error(param_p, NIDL_CTXPTRVOID);
type_is_pointer = (deref_type_p != top_type_p);
if (type_is_pointer
&& (AST_CONTEXT_SET(param_p) || AST_CONTEXT_RD_SET(deref_type_p))
&& AST_UNIQUE_SET(param_p))
CHECKER_error(param_p, NIDL_UNIQCTXHAN);
if (type_is_pointer
&& (AST_CONTEXT_SET(param_p) || AST_CONTEXT_RD_SET(deref_type_p))
&& AST_PTR_SET(param_p)
&& deref_type_p->kind != AST_structure_k)
CHECKER_error(param_p, NIDL_PTRCTXHAN);
}
static void param_varying
(
AST_parameter_n_t *param_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
if (type_p->kind != AST_array_k)
return;
if (!AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL
&& AST_VARYING_SET(param_p)
&& instance_is_varying_upper(type_p->type_structure.array,
param_p->field_attrs)
&& (*(int *)cmd_val[opt_standard] <= opt_standard_dce_1_0))
CHECKER_warning(param_p, NIDL_NOPORTVARY, OPT_STD_EXTENDED);
}
static void param_direction
(
AST_parameter_n_t *param_p,
AST_type_n_t *top_type_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
type_p = type_xmit_type(type_p);
if (type_p->kind != AST_void_k
&& !AST_LOCAL_SET(int_p)
&& !AST_IN_SET(param_p)
&& !AST_OUT_SET(param_p))
CHECKER_error(param_p, NIDL_PRMINOROUT);
if (AST_OUT_SET(param_p)
&& top_type_p->kind != AST_array_k
&& param_p->uplink->result != param_p
&& ((top_type_p->kind != AST_pointer_k
&& top_type_p->kind != AST_pipe_k)
|| (top_type_p->kind == AST_pointer_k
&& top_type_p->type_structure.pointer->pointee_type->kind
== AST_void_k)
|| (top_type_p->kind == AST_pointer_k
&& top_type_p->type_structure.pointer->pointee_type->kind == AST_interface_k)
))
CHECKER_error(param_p, NIDL_OUTPRMREF);
if (!AST_LOCAL_SET(int_p)
&& AST_OUT_SET(param_p)
&& param_p->uplink->result != param_p
&& top_type_p->kind == AST_pointer_k
&& top_type_p->type_structure.pointer->pointee_type->kind
!= AST_function_k
&& top_type_p->name != NAMETABLE_NIL_ID)
CHECKER_error(param_p, NIDL_OUTSTAR);
if (AST_OUT_SET(param_p)
&& type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind
== AST_function_k)
CHECKER_error(param_p, NIDL_FPINPRM);
if (AST_IN_SHAPE_SET(param_p))
CHECKER_error(param_p, NIDL_NYSINSHAPE);
if (AST_OUT_SHAPE_SET(param_p))
CHECKER_error(param_p, NIDL_NYSOUTSHAPE);
if (type_p->kind == AST_pointer_k)
type_p = ASTP_chase_ptr_to_kind(type_p, AST_disc_union_k);
if (AST_IN_SET(param_p)
&& type_p != NULL
&& type_p->kind == AST_disc_union_k
&& type_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID
&& param_p->field_attrs != NULL
&& param_p->field_attrs->switch_is != NULL
&& !AST_IN_SET(param_p->field_attrs->switch_is->ref.p_ref))
CHECKER_error(param_p, NIDL_DISCRIMIN);
#if 0
if (AST_OUT_SET(param_p)
&& type_p != NULL
&& type_p->kind == AST_disc_union_k
&& type_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID
&& param_p->field_attrs != NULL
&& param_p->field_attrs->switch_is != NULL
&& !AST_OUT_SET(param_p->field_attrs->switch_is->ref.p_ref))
CHECKER_error(param_p, NIDL_DISCRIMOUT);
#endif
}
static void param_comm_status
(
AST_parameter_n_t *param_p,
AST_type_n_t *type_p
)
{
char const *type_name;
if (AST_COMM_STATUS_SET(param_p)
&& param_p != param_p->uplink->result
&& !AST_OUT_SET(param_p))
CHECKER_error(param_p, NIDL_STSPRMOUT,
acf_keyword_lookup(COMM_STATUS_KW));
if (AST_FAULT_STATUS_SET(param_p)
&& param_p != param_p->uplink->result
&& !AST_OUT_SET(param_p))
CHECKER_error(param_p, NIDL_STSPRMOUT,
acf_keyword_lookup(FAULT_STATUS_KW));
while (type_p->defined_as != NULL)
type_p = type_p->defined_as;
NAMETABLE_id_to_string(type_p->name, &type_name);
if (AST_COMM_STATUS_SET(param_p)
&& param_p != param_p->uplink->result
&& strcmp(type_name, "error_status_t") != 0)
CHECKER_error(param_p, NIDL_STSVARTYPE,
acf_keyword_lookup(COMM_STATUS_KW));
if (AST_FAULT_STATUS_SET(param_p)
&& param_p != param_p->uplink->result
&& strcmp(type_name, "error_status_t") != 0)
CHECKER_error(param_p, NIDL_STSVARTYPE,
acf_keyword_lookup(FAULT_STATUS_KW));
if (AST_COMM_STATUS_SET(param_p)
&& param_p == param_p->uplink->result
&& strcmp(type_name, "error_status_t") != 0)
CHECKER_error(param_p->uplink, NIDL_STSRETVAL,
acf_keyword_lookup(COMM_STATUS_KW));
if (AST_FAULT_STATUS_SET(param_p)
&& param_p == param_p->uplink->result
&& strcmp(type_name, "error_status_t") != 0)
CHECKER_error(param_p->uplink, NIDL_STSRETVAL,
acf_keyword_lookup(FAULT_STATUS_KW));
}
static void param_switch_is
(
AST_parameter_n_t *param_p,
AST_type_n_t *type_p
)
{
if (type_p->kind == AST_pointer_k)
type_p = ASTP_chase_ptr_to_kind(type_p, AST_disc_union_k);
if (type_p != NULL
&& type_p->kind == AST_disc_union_k
&& type_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID
&& (param_p->field_attrs == NULL
|| param_p->field_attrs->switch_is == NULL))
CHECKER_error(param_p, NIDL_NEUSWATTR);
}
static void param_first_handle
(
AST_parameter_n_t *param_p,
AST_interface_n_t *int_p
)
{
AST_operation_n_t *op_p;
AST_type_n_t *type_p;
op_p = param_p->uplink;
type_p = param_follow_ref_ptr(param_p, CHK_follow_any);
if (int_p->implicit_handle_name == NAMETABLE_NIL_ID
&& !AST_OBJECT_SET(int_p)
&& !AST_AUTO_HANDLE_SET(int_p)
&& !AST_LOCAL_SET(int_p)
&& !type_is_handle(type_p)
&& !AST_HAS_IN_CTX_SET(op_p))
default_to_auto_handle(op_p, NIDL_DEFAUTOHAN);
#if 0
else if (int_p->implicit_handle_name == NAMETABLE_NIL_ID
&& !AST_AUTO_HANDLE_SET(int_p)
&& !AST_LOCAL_SET(int_p)
&& !type_is_handle(type_p)
&& AST_HAS_IN_OUT_CTX_SET(op_p))
default_to_auto_handle(op_p, NIDL_POSSAUTOHAN);
#endif
if (!AST_LOCAL_SET(int_p)
&& type_p->kind == AST_handle_k
&& (!AST_IN_SET(param_p) || AST_OUT_SET(param_p)))
CHECKER_error(param_p, NIDL_HANPRMIN);
if (!AST_LOCAL_SET(int_p)
&& AST_HANDLE_SET(type_p)
&& !AST_IN_SET(param_p))
CHECKER_error(param_p, NIDL_HANDLEIN);
if (!AST_LOCAL_SET(int_p)
&& type_is_handle(type_p)
&& AST_PTR_SET(param_p))
CHECKER_error(param_p, NIDL_PTRATTRHAN);
if (!AST_LOCAL_SET(int_p)
&& type_is_handle(type_p)
&& AST_UNIQUE_SET(param_p))
CHECKER_error(param_p, NIDL_UNIQATTRHAN);
if (!AST_LOCAL_SET(int_p)
&& type_p->kind == AST_handle_k
&& !AST_HANDLE_SET(type_p)
&& type_p->xmit_as_type != NULL)
CHECKER_error(param_p, NIDL_HANXMITAS);
if (AST_HANDLE_SET(type_p)
&& type_p->defined_as != NULL
&& FE_TEST(type_p->defined_as->fe_info->flags, FE_HAS_XMIT_AS))
{
ASTP_attr_flag_t attr1 = ASTP_TRANSMIT_AS;
ASTP_attr_flag_t attr2 = ASTP_HANDLE;
CHECKER_error(param_p, NIDL_TYPEATTRUSE,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)),
KEYWORDS_lookup_text(AST_attribute_to_token(&attr2)));
}
if (type_p->xmit_as_type != NULL
&& type_p->defined_as != NULL
&& AST_HANDLE_SET(type_p->defined_as))
{
ASTP_attr_flag_t attr1 = ASTP_HANDLE;
ASTP_attr_flag_t attr2 = ASTP_TRANSMIT_AS;
CHECKER_error(param_p, NIDL_TYPEATTRUSE,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)),
KEYWORDS_lookup_text(AST_attribute_to_token(&attr2)));
}
}
static void param_check_first
(
AST_parameter_n_t *param_p,
AST_interface_n_t *int_p
)
{
param_first_handle(param_p, int_p);
}
static void param_check_non_handle
(
AST_parameter_n_t *param_p,
AST_interface_n_t *int_p
)
{
AST_type_n_t *type_p;
type_p = param_follow_ref_ptr(param_p, CHK_follow_ref);
if (!AST_LOCAL_SET(int_p)
&& type_p->kind == AST_handle_k
&& type_p->xmit_as_type == NULL)
CHECKER_error(param_p, NIDL_HANFIRSTPRM);
}
static void param_check
(
AST_parameter_n_t *param_p,
AST_interface_n_t *int_p
)
{
AST_field_attr_n_t *fattr_p;
AST_type_n_t *top_type_p;
AST_type_n_t *type_p;
AST_type_n_t *deref_type_p;
top_type_p = param_p->type;
type_p = param_follow_ref_ptr(param_p, CHK_follow_ref);
deref_type_p = param_follow_ref_ptr(param_p, CHK_follow_any);
param_type(param_p, top_type_p, type_p, int_p);
fattr_p = param_p->field_attrs;
if (fattr_p != NULL)
{
fattr_check(fattr_p, (ASTP_node_t *)param_p, type_p, int_p);
fattr_param_check(fattr_p, param_p, int_p);
}
if (type_p->kind == AST_interface_k) {
char const * id_name;
NAMETABLE_id_to_string(type_p->name, &id_name);
CHECKER_error(param_p, NIDL_INTREFNOTALO, id_name);
}
param_size(param_p, top_type_p, type_p, int_p);
param_struct(param_p, top_type_p, type_p);
param_pipe(param_p, top_type_p, deref_type_p);
param_in_line(param_p, type_p);
param_string(param_p, type_p);
param_pointer(param_p, top_type_p, type_p, int_p);
param_small(param_p, top_type_p, type_p);
param_context(param_p, top_type_p, deref_type_p);
param_varying(param_p, type_p, int_p);
param_direction(param_p, top_type_p, type_p, int_p);
param_comm_status(param_p, type_p);
param_switch_is(param_p, type_p);
CHK_param_cs(param_p, type_p);
}
static void op_handle
(
AST_operation_n_t *op_p,
AST_interface_n_t *int_p
)
{
if (int_p->implicit_handle_name == NAMETABLE_NIL_ID
&& !AST_AUTO_HANDLE_SET(int_p)
&& !AST_LOCAL_SET(int_p)
&& !AST_OBJECT_SET(int_p)
&& op_p->parameters == NULL)
default_to_auto_handle(op_p, NIDL_DEFAUTOHAN);
}
static void op_comm_status
(
AST_operation_n_t *op_p
)
{
AST_parameter_n_t *param_p;
int comm_status_count;
int fault_status_count;
comm_status_count = 0;
fault_status_count = 0;
if (AST_COMM_STATUS_SET(op_p->result))
comm_status_count++;
if (AST_FAULT_STATUS_SET(op_p->result))
fault_status_count++;
for (param_p = op_p->parameters; param_p != NULL; param_p = param_p->next)
{
if (AST_COMM_STATUS_SET(param_p) || AST_ADD_COMM_STATUS_SET(param_p))
comm_status_count++;
if (AST_FAULT_STATUS_SET(param_p) || AST_ADD_FAULT_STATUS_SET(param_p))
fault_status_count++;
}
if (comm_status_count > 1)
CHECKER_acf_error(op_p, NIDL_STSATTRONCE,
acf_keyword_lookup(COMM_STATUS_KW));
if (fault_status_count > 1)
CHECKER_acf_error(op_p, NIDL_STSATTRONCE,
acf_keyword_lookup(FAULT_STATUS_KW));
}
static void op_broadcast
(
AST_operation_n_t *op_p
)
{
if (AST_BROADCAST_SET(op_p)
&& (AST_HAS_IN_PIPES_SET(op_p) || AST_HAS_OUT_PIPES_SET(op_p)))
CHECKER_error(op_p, NIDL_BROADPIPE);
}
static void op_maybe
(
AST_operation_n_t *op_p
)
{
if (AST_MAYBE_SET(op_p)
&& (AST_HAS_OUTS_SET(op_p) || AST_HAS_OUT_PIPES_SET(op_p)))
CHECKER_error(op_p, NIDL_MAYBEOUTPRM);
}
static void op_code
(
AST_operation_n_t *op_p
)
{
if (AST_CODE_SET(op_p)
&& AST_NO_CODE_SET(op_p))
CHECKER_acf_error(op_p, NIDL_OPCODEATTR);
if (AST_NO_CODE_SET(op_p)
&& cmd_opt[opt_emit_sstub]
&& !cmd_opt[opt_emit_cstub])
CHECKER_acf_warning(op_p, NIDL_SRVNOCODE);
}
static void op_idempotent
(
AST_operation_n_t *op_p
)
{
if (AST_IDEMPOTENT_SET(op_p)
&& !AST_BROADCAST_SET(op_p)
&& (AST_HAS_IN_PIPES_SET(op_p) || AST_HAS_OUT_PIPES_SET(op_p)))
CHECKER_error(op_p, NIDL_IDEMPIPE);
}
static void op_encode
(
AST_operation_n_t *op_p
)
{
AST_parameter_n_t *param_p;
AST_parameter_n_t *p1;
boolean all_in_out;
boolean all_in;
boolean all_out;
boolean p1_is_handle_t;
if (AST_NO_CODE_SET(op_p))
return;
if (!AST_ENCODE_SET(op_p) && !AST_DECODE_SET(op_p))
return;
all_in_out = TRUE;
all_in = TRUE;
all_out = TRUE;
p1 = op_p->parameters;
if (p1 != NULL
&& (p1->type->kind == AST_handle_k
|| (p1->type->kind == AST_pointer_k
&& p1->type->type_structure.pointer->pointee_type->kind
== AST_handle_k)))
p1_is_handle_t = TRUE;
else
p1_is_handle_t = FALSE;
param_p = ((p1 != NULL) ? p1 : op_p->result);
while (TRUE)
{
if (AST_IN_SET(param_p) && !AST_OUT_SET(param_p))
{
if ( !(param_p == p1 && p1_is_handle_t) )
{
all_out = FALSE;
all_in_out = FALSE;
}
}
else if (!AST_IN_SET(param_p) && AST_OUT_SET(param_p))
{
if (!AST_ADD_COMM_STATUS_SET(param_p)
&& !AST_ADD_FAULT_STATUS_SET(param_p))
{
all_in = FALSE;
all_in_out = FALSE;
}
}
else if (AST_IN_SET(param_p) && AST_OUT_SET(param_p))
{
all_in = FALSE;
all_out = FALSE;
}
if (AST_ENCODE_SET(op_p) && !AST_DECODE_SET(op_p)
&& AST_OUT_SET(param_p) && !AST_IN_SET(param_p)
&& !AST_ADD_COMM_STATUS_SET(param_p)
&& !AST_ADD_FAULT_STATUS_SET(param_p))
{
char const *id_name;
NAMETABLE_id_to_string(param_p->name, &id_name);
CHECKER_warning(param_p, NIDL_ENCOUTONLY, id_name);
}
if (AST_DECODE_SET(op_p) && !AST_ENCODE_SET(op_p)
&& AST_IN_SET(param_p) && !AST_OUT_SET(param_p)
&& !(param_p == p1 && p1_is_handle_t) )
{
char const *id_name;
NAMETABLE_id_to_string(param_p->name, &id_name);
CHECKER_warning(param_p, NIDL_DECINONLY, id_name);
}
if (AST_FAULT_STATUS_SET(param_p) || AST_ADD_FAULT_STATUS_SET(param_p))
CHECKER_acf_warning(op_p, NIDL_NOFLTPARAM);
if (param_p == op_p->result)
break;
param_p = param_p->next;
if (param_p == NULL)
param_p = op_p->result;
}
if (AST_ENCODE_SET(op_p) && !AST_DECODE_SET(op_p) && all_out)
CHECKER_error(op_p, NIDL_ENCNOPARAMS);
if (AST_DECODE_SET(op_p) && !AST_ENCODE_SET(op_p) && all_in)
CHECKER_error(op_p, NIDL_DECNOPARAMS);
if (AST_ENCODE_SET(op_p) && AST_DECODE_SET(op_p) && !all_in_out)
CHECKER_error(op_p, NIDL_ENCDECDIR);
if ( (AST_ENCODE_SET(op_p) || AST_DECODE_SET(op_p))
&& (AST_HAS_IN_PIPES_SET(op_p) || AST_HAS_OUT_PIPES_SET(op_p)) )
CHECKER_error(op_p, NIDL_ENCDECPIPE);
if ( (AST_ENCODE_SET(op_p) || AST_DECODE_SET(op_p))
&& !p1_is_handle_t )
CHECKER_error(op_p, NIDL_ENCDECBIND);
if (AST_ENCODE_SET(op_p)
&& (*(int *)cmd_val[opt_standard] < opt_standard_dce_1_1))
CHECKER_acf_warning(op_p, NIDL_NOPORTATTR, "encode", OPT_STD_EXTENDED);
if (AST_DECODE_SET(op_p)
&& (*(int *)cmd_val[opt_standard] < opt_standard_dce_1_1))
CHECKER_acf_warning(op_p, NIDL_NOPORTATTR, "decode", OPT_STD_EXTENDED);
}
static void operation_check
(
AST_operation_n_t *op_p,
AST_interface_n_t *int_p
)
{
AST_parameter_n_t *param_p;
op_handle(op_p, int_p);
op_comm_status(op_p);
op_broadcast(op_p);
op_maybe(op_p);
op_code(op_p);
op_idempotent(op_p);
op_encode(op_p);
CHK_op_cs(op_p);
if (FE_TEST(op_p->fe_info->flags, FE_HAS_VAL_FLOAT)
)
{
char const *id_name;
NAMETABLE_id_to_string(op_p->name, &id_name);
CHECKER_warning(op_p, NIDL_FLOATPROM, id_name);
}
if (AST_REFLECT_DELETIONS_SET(op_p)
&& !FE_TEST(op_p->fe_info->flags, FE_HAS_IN_FULL_PTR))
CHECKER_warning(op_p, NIDL_OPREFDELIN);
if (AST_REFLECT_DELETIONS_SET(op_p)
&& (*(int *)cmd_val[opt_standard] < opt_standard_dce_1_1))
{
ASTP_attr_flag_t attr1 = ASTP_REFLECT_DELETIONS;
CHECKER_warning(op_p, NIDL_NOPORTATTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)),
OPT_STD_EXTENDED);
}
param_p = op_p->parameters;
if (param_p != NULL)
{
param_check_first(param_p, int_p);
param_check(param_p, int_p);
while ((param_p = param_p->next) != NULL)
{
param_check_non_handle(param_p, int_p);
param_check(param_p, int_p);
}
}
if (op_p->result != NULL)
{
param_check_non_handle(op_p->result, int_p);
param_check(op_p->result, int_p);
}
}
static void field_type
(
AST_field_n_t *field_p,
AST_interface_n_t *int_p
)
{
AST_type_n_t *type_p;
type_p = field_p->type;
if (type_is_anonymous(type_p))
type_check(type_p, (ASTP_node_t *)field_p, int_p);
if (type_p->xmit_as_type != NULL
&&
(AST_STRING_SET(field_p)
|| AST_STRING0_SET(field_p)
|| AST_UNIQUE_SET(field_p)
|| AST_REF_SET(field_p)
|| AST_IGNORE_SET(field_p)
|| AST_SMALL_SET(field_p)
|| AST_CONTEXT_SET(field_p)
|| AST_PTR_SET(field_p)))
CHECKER_error(field_p, NIDL_XMITTYPEATTRS);
if (type_p->xmit_as_type != NULL
&& AST_CONFORMANT_SET(type_p->xmit_as_type))
CHECKER_error(field_p, NIDL_FLDXMITCFMT);
type_p = type_xmit_type(type_p);
if (!AST_LOCAL_SET(int_p)
&& field_p->next != NULL
&& AST_CONFORMANT_SET(type_p)
&& type_p->kind != AST_pointer_k)
CHECKER_error(field_p, NIDL_CFMTFLDLAST);
if (type_p->kind == AST_pipe_k)
CHECKER_error(field_p, NIDL_PIPESTRFLD);
if (type_p->kind == AST_interface_k) {
char const * id_name;
NAMETABLE_id_to_string(type_p->name, &id_name);
CHECKER_error(field_p, NIDL_INTREFNOTALO, id_name);
}
if (AST_CONTEXT_RD_SET(type_p)
|| AST_CONTEXT_SET(field_p))
CHECKER_error(field_p, NIDL_CTXSTRFLD);
if (!AST_LOCAL_SET(int_p)
&& type_is_function(type_p)
&& type_p->xmit_as_type == NULL
)
CHECKER_error(field_p, NIDL_FPSTRFLD);
if (type_p->kind == AST_handle_k)
#if 0
&& type_p->xmit_as_type == NULL)
#endif
CHECKER_error(field_p, NIDL_HANSTRFLD);
if (type_p->kind == AST_void_k)
CHECKER_error(field_p, NIDL_VOIDOPPTR);
if (!AST_LOCAL_SET(int_p)
&& type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind == AST_void_k
&& !AST_CONTEXT_RD_SET(type_p)
&& !AST_CONTEXT_SET(field_p)
)
CHECKER_error(field_p, NIDL_PTRVOIDCTX);
if (FE_TEST(field_p->fe_info->flags, FE_HAS_V1_ATTR)
&& FE_TEST(field_p->fe_info->flags, FE_HAS_V2_ATTR)
&& ! ( FE_TEST(type_p->fe_info->flags, FE_HAS_V1_ATTR)
&& FE_TEST(type_p->fe_info->flags, FE_HAS_V2_ATTR) ))
CHECKER_warning(field_p, NIDL_INCOMPATV1);
}
static void field_size
(
AST_field_n_t *field_p,
AST_interface_n_t *int_p
)
{
AST_type_n_t *type_p;
AST_field_attr_n_t *fattr_p;
type_p = field_p->type;
fattr_p = field_p->field_attrs;
if (!AST_LOCAL_SET(int_p)
&& type_p->kind != AST_structure_k
&& type_p->xmit_as_type == NULL
&& fattr_p == NULL
&& (AST_CONFORMANT_SET(type_p)
|| AST_VARYING_SET(field_p))
&& !AST_STRING_SET(type_p)
&& !AST_STRING_SET(field_p))
{
char const *id_name;
NAMETABLE_id_to_string(field_p->name, &id_name);
CHECKER_error(field_p, NIDL_ARRSIZEINFO, id_name);
}
if (!AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL
&& AST_STRING_SET(field_p)
&& fattr_p != NULL
&& (fattr_p->first_is_vec != NULL
|| fattr_p->last_is_vec != NULL
|| fattr_p->length_is_vec != NULL))
CHECKER_error(field_p, NIDL_STRVARY);
if (type_p->xmit_as_type != NULL
&& fattr_p != NULL
&& type_p->kind != AST_pointer_k)
CHECKER_error(field_p, NIDL_ARRXMITOPEN);
if (type_p->kind == AST_pointer_k)
{
AST_type_n_t *ref_type_p;
ref_type_p = ASTP_chase_ptr_to_type(type_p);
if (ref_type_p->kind == AST_array_k
&& !AST_CONFORMANT_SET(ref_type_p)
&& fattr_p != NULL
&& (fattr_p->min_is_vec != NULL
|| fattr_p->max_is_vec != NULL
|| fattr_p->size_is_vec != NULL))
CHECKER_error(field_p, NIDL_ARRSYNTAX);
if (ref_type_p->kind == AST_array_k
&& AST_CONFORMANT_SET(ref_type_p)
&& (!AST_STRING_SET(ref_type_p)
|| (fattr_p != NULL
&& (fattr_p->min_is_vec != NULL
|| fattr_p->max_is_vec != NULL
|| fattr_p->size_is_vec != NULL))))
{
CHECKER_error(field_p, NIDL_PTRCFMTARR);
return;
}
if (ref_type_p->kind == AST_array_k
&& fattr_p != NULL
&& (fattr_p->first_is_vec != NULL
|| fattr_p->last_is_vec != NULL
|| fattr_p->length_is_vec != NULL))
{
CHECKER_error(field_p, NIDL_PTRVARYARR);
return;
}
}
}
static void field_in_line
(
AST_field_n_t *field_p
)
{
AST_type_n_t *type_p;
type_p = field_p->type;
if (AST_IN_LINE_SET(field_p)
&& AST_OUT_OF_LINE_SET(field_p))
CHECKER_acf_error(field_p, NIDL_CONFLINEATTR);
if ((AST_IN_LINE_SET(field_p) || AST_OUT_OF_LINE_SET(field_p))
&& type_is_scalar(type_p))
{
char const *file_name;
char const *type_name;
STRTAB_str_to_string(type_p->fe_info->file, &file_name);
NAMETABLE_id_to_string(type_p->name, &type_name);
CHECKER_acf_warning(field_p, NIDL_LINENONSCAL);
CHECKER_acf_warning(field_p, NIDL_NAMEDECLAT, type_name, file_name,
type_p->fe_info->source_line);
}
}
static void field_string
(
AST_field_n_t *field_p
)
{
AST_type_n_t *type_p;
type_p = field_p->type;
if (AST_STRING0_SET(field_p)
&& !type_is_v1_string(type_p))
CHECKER_error(field_p, NIDL_STRV1FIXED);
if ((AST_STRING0_SET(field_p) || AST_STRING0_SET(type_p))
&& !(AST_SMALL_SET(field_p) || AST_SMALL_SET(type_p)))
CHECKER_error(field_p, NIDL_STRV1ARRAY);
if ((AST_STRING_SET(field_p) && AST_SMALL_SET(field_p))
|| (AST_STRING_SET(field_p) && AST_SMALL_SET(type_p))
|| (AST_STRING_SET(type_p) && AST_SMALL_SET(field_p)))
CHECKER_error(field_p, NIDL_STRARRAYV1);
if ( (AST_STRING_SET(field_p) || AST_STRING_SET(type_p))
&& (AST_STRING0_SET(field_p) || AST_STRING0_SET(type_p)) )
{
ASTP_attr_flag_t attr1 = ASTP_STRING;
ASTP_attr_flag_t attr2 = ASTP_STRING0;
CHECKER_error(field_p, NIDL_CONFLICTATTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)),
KEYWORDS_lookup_text(AST_attribute_to_token(&attr2)));
}
if (type_p->kind == AST_pointer_k)
{
AST_type_n_t *ref_type_p;
ref_type_p = ASTP_chase_ptr_to_type(type_p);
if (ref_type_p->kind == AST_array_k
&& (field_p->field_attrs != NULL
|| (AST_CONFORMANT_SET(ref_type_p)
&& !AST_STRING_SET(ref_type_p))))
return;
}
if (AST_STRING_SET(field_p)
&& !type_is_string(type_p))
CHECKER_error(field_p, NIDL_STRCHARBYTE);
}
static void field_pointer
(
AST_field_n_t *field_p,
AST_interface_n_t *int_p
)
{
AST_type_n_t *type_p;
boolean pointer_attr_valid = FALSE;
type_p = field_p->type;
if (type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind != AST_void_k)
pointer_attr_valid = TRUE;
if (AST_REF_SET(field_p) && !pointer_attr_valid)
CHECKER_error(field_p, NIDL_REFATTRPTR);
if (AST_UNIQUE_SET(field_p) && !pointer_attr_valid)
CHECKER_error(field_p, NIDL_UNIQATTRPTR);
if (AST_PTR_SET(field_p) && !pointer_attr_valid)
CHECKER_error(field_p, NIDL_PTRATTRPTR);
if (AST_UNIQUE_SET(field_p)
&& (*(int *)cmd_val[opt_standard] <= opt_standard_dce_1_0))
CHECKER_warning(field_p, NIDL_NOPORTUNIQUE, OPT_STD_EXTENDED);
if (type_p->kind == AST_array_k &&
(AST_REF_SET(field_p) || AST_PTR_SET(field_p) || AST_UNIQUE_SET(field_p)))
CHECKER_error(field_p, NIDL_ARRPTRPRM);
#if 0
if (type_p->kind == AST_pointer_k && type_p->type_structure.pointer->pointee_type->kind == AST_interface_k
&& (AST_UNIQUE_SET(field_p) || AST_REF_SET(field_p) || AST_PTR_SET(field_p)))
CHECKER_warning(field_p, NIDL_PTRATTBIGN);
#endif
if (type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind != AST_array_k
#if 0
&& (field_p->field_attrs != NULL
#endif
&& (instance_has_array_attr(field_p)
|| AST_STRING_SET(type_p)
|| AST_STRING_SET(field_p)))
{
array_check((ASTP_node_t *)type_p->type_structure.pointer,
type_p,
(ASTP_node_t *)field_p,
type_p->type_structure.pointer->pointee_type,
int_p,
true);
}
}
static void field_small
(
AST_field_n_t *field_p
)
{
AST_type_n_t *type_p;
AST_array_n_t *array_p;
AST_field_attr_n_t *fattr_p;
type_p = field_p->type;
if (AST_SMALL_SET(field_p)
&& type_p->kind == AST_pointer_k)
CHECKER_error(field_p, NIDL_SMALLARRSYN);
if (!type_is_array_np(type_p))
return;
fattr_p = field_p->field_attrs;
array_p = type_p->type_structure.array;
if (AST_SMALL_SET(field_p)
&& ((AST_CONFORMANT_SET(type_p)
&& array_is_conformant_upper(array_p))
||
(AST_VARYING_SET(field_p)
&& instance_is_varying_upper(array_p, field_p->field_attrs))))
CHECKER_error(field_p, NIDL_SMALLMULTID);
if (AST_SMALL_SET(field_p)
&& array_is_large(array_p))
CHECKER_error(field_p, NIDL_SMALLINV);
if ((AST_SMALL_SET(type_p) || AST_SMALL_SET(field_p))
&& AST_CONFORMANT_SET(type_p)
&& !AST_VARYING_SET(field_p))
CHECKER_error(field_p, NIDL_SMALLCFMT);
if ((AST_SMALL_SET(type_p) || AST_SMALL_SET(field_p))
&& fattr_p != NULL
&& (fattr_p->min_is_vec != NULL
|| fattr_p->first_is_vec != NULL))
CHECKER_error(field_p, NIDL_SMALLMINFIRST);
}
static void field_context
(
AST_field_n_t *field_p
)
{
AST_type_n_t *type_p;
type_p = field_p->type;
if (AST_CONTEXT_SET(field_p)
&& (type_p->kind != AST_pointer_k
|| (type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind
!= AST_void_k)))
CHECKER_error(field_p, NIDL_CTXPTRVOID);
if (AST_UNIQUE_SET(field_p)
&& type_p->kind == AST_pointer_k
&& AST_CONTEXT_RD_SET(type_p->type_structure.pointer->pointee_type))
CHECKER_error(field_p, NIDL_UNIQCTXHAN);
if (AST_PTR_SET(field_p)
&& type_p->kind == AST_pointer_k
&& AST_CONTEXT_RD_SET(type_p->type_structure.pointer->pointee_type))
CHECKER_error(field_p, NIDL_PTRCTXHAN);
}
static void field_varying
(
AST_field_n_t *field_p,
AST_interface_n_t *int_p
)
{
AST_type_n_t *type_p;
type_p = field_p->type;
if (type_p->kind != AST_array_k)
return;
if (!AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL
&& AST_VARYING_SET(field_p)
&& instance_is_varying_upper(type_p->type_structure.array,
field_p->field_attrs)
&& (*(int *)cmd_val[opt_standard] <= opt_standard_dce_1_0))
CHECKER_warning(field_p, NIDL_NOPORTVARY, OPT_STD_EXTENDED);
}
static void field_ignore
(
AST_field_n_t *field_p
)
{
AST_type_n_t *type_p;
type_p = field_p->type;
if (AST_IGNORE_SET(field_p)
&& type_p->kind != AST_pointer_k)
CHECKER_error(field_p, NIDL_IGNATTRPTR);
}
static void field_switch_is
(
AST_field_n_t *field_p
)
{
AST_type_n_t *type_p;
type_p = field_p->type;
if (type_p->kind == AST_pointer_k)
type_p = ASTP_chase_ptr_to_kind(type_p, AST_disc_union_k);
if (type_p != NULL
&& type_p->kind == AST_disc_union_k
&& type_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID
&& (field_p->field_attrs == NULL
|| field_p->field_attrs->switch_is == NULL))
CHECKER_error(field_p, NIDL_NEUSWATTR);
}
static void field_check
(
AST_field_n_t *field_p,
AST_interface_n_t *int_p
)
{
AST_field_attr_n_t *fattr_p;
field_type(field_p, int_p);
field_size(field_p, int_p);
field_in_line(field_p);
field_string(field_p);
field_pointer(field_p, int_p);
field_small(field_p);
field_context(field_p);
field_varying(field_p, int_p);
field_ignore(field_p);
field_switch_is(field_p);
CHK_field_cs(field_p);
fattr_p = field_p->field_attrs;
if (fattr_p != NULL)
fattr_check(fattr_p, (ASTP_node_t *)field_p, field_p->type, int_p);
}
static void struct_check
(
AST_structure_n_t *struct_p,
AST_interface_n_t *int_p
)
{
AST_field_n_t *field_p;
field_p = struct_p->fields;
while (field_p != NULL)
{
field_check(field_p, int_p);
field_p = field_p->next;
}
}
static void fp_param_handle
(
AST_parameter_n_t *param_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
type_p = type_xmit_type(type_p);
if (!AST_LOCAL_SET(int_p)
&& type_p->kind == AST_handle_k)
CHECKER_error(param_p, NIDL_FPHANPRM);
#if 0
if (AST_HANDLE_SET(type_p))
CHECKER_warning(param_p, NIDL_FPHANATTR);
#endif
}
static void fp_param_check
(
AST_parameter_n_t *param_p,
AST_interface_n_t *int_p
)
{
AST_field_attr_n_t *fattr_p;
AST_type_n_t *top_type_p;
AST_type_n_t *type_p;
AST_type_n_t *deref_type_p;
top_type_p = param_p->type;
type_p = param_follow_ref_ptr(param_p, CHK_follow_ref);
deref_type_p = param_follow_ref_ptr(param_p, CHK_follow_any);
param_type(param_p, top_type_p, type_p, int_p);
fattr_p = param_p->field_attrs;
if (fattr_p != NULL)
fattr_check(fattr_p, (ASTP_node_t *)param_p, param_p->type, int_p);
param_size(param_p, top_type_p, type_p, int_p);
param_struct(param_p, top_type_p, type_p);
param_pipe(param_p, top_type_p, deref_type_p);
param_string(param_p, type_p);
param_pointer(param_p, top_type_p, type_p, int_p);
param_small(param_p, top_type_p, type_p);
param_context(param_p, top_type_p, deref_type_p);
param_varying(param_p, type_p, int_p);
fp_param_handle(param_p, type_p, int_p);
}
static void function_ptr_check
(
AST_operation_n_t *op_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
AST_parameter_n_t *param_p;
if (!AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL)
CHECKER_error(op_p, NIDL_FPLOCINT);
for (param_p = op_p->parameters; param_p != NULL; param_p = param_p->next)
fp_param_check(param_p, int_p);
if (op_p->result != NULL)
fp_param_check(op_p->result, int_p);
}
static void ptr_pointee_type
(
AST_pointer_n_t *ptr_p,
AST_type_n_t *ptr_type_p,
ASTP_node_t *node_p,
AST_interface_n_t *int_p
)
{
AST_type_n_t *type_p;
type_p = ptr_p->pointee_type;
if ( (node_p->fe_info->node_kind == fe_parameter_n_k
&& ((AST_parameter_n_t *)node_p)->field_attrs != NULL)
|| (node_p->fe_info->node_kind == fe_field_n_k
&& ((AST_field_n_t *)node_p)->field_attrs != NULL))
return;
if (type_p->kind == AST_pipe_k
&& node_p->fe_info->node_kind != fe_parameter_n_k)
CHECKER_error(ptr_p, NIDL_INVPTRPIPE);
if (AST_CONTEXT_RD_SET(type_p)
&& node_p->fe_info->node_kind != fe_parameter_n_k
&& !(node_p->fe_info->node_kind == fe_export_n_k
&& type_p->kind == AST_structure_k
&& AST_DEF_AS_TAG_SET(type_p)))
CHECKER_error(ptr_p, NIDL_INVPTRCTX);
if (type_p->kind == AST_handle_k
&& node_p->fe_info->node_kind != fe_parameter_n_k)
CHECKER_error(ptr_p, NIDL_HANDLEPTR);
if (!AST_LOCAL_SET(int_p)
&& type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind == AST_void_k
&& !AST_CONTEXT_RD_SET(type_p)
&& !(node_p->fe_info->node_kind == fe_parameter_n_k
&& AST_CONTEXT_SET((AST_parameter_n_t *)node_p))
)
CHECKER_error(node_p, NIDL_PTRVOIDCTX);
if (type_p->kind == AST_function_k)
function_ptr_check(type_p->type_structure.function, ptr_type_p, int_p);
}
static void ptr_check
(
AST_pointer_n_t *ptr_p,
AST_type_n_t *ptr_type_p,
ASTP_node_t *node_p,
AST_interface_n_t *int_p
)
{
ptr_pointee_type(ptr_p, ptr_type_p, node_p, int_p);
}
static void pipe_base_type
(
AST_pipe_n_t *pipe_p,
AST_interface_n_t *int_p
)
{
AST_type_n_t *type_p;
type_p = pipe_p->base_type;
if (type_is_anonymous(type_p))
type_check(type_p, (ASTP_node_t *)pipe_p, int_p);
if (type_p->kind == AST_pipe_k)
CHECKER_error(pipe_p, NIDL_PIPEBASETYP);
if (AST_CONTEXT_RD_SET(type_p))
CHECKER_error(pipe_p, NIDL_CTXBASETYP);
if (AST_CONFORMANT_SET(type_p))
CHECKER_error(pipe_p, NIDL_CFMTBASETYP);
if (type_p->kind == AST_handle_k)
CHECKER_error(pipe_p, NIDL_HANPIPEBASE);
if (type_is_function(type_p))
CHECKER_error(pipe_p, NIDL_FPPIPEBASE);
if (type_p->kind == AST_interface_k)
CHECKER_error(pipe_p, NIDL_PIPECTYPE, "interface");
if (type_p->kind == AST_pointer_k && type_p->type_structure.pointer->pointee_type->kind == AST_interface_k)
CHECKER_error(pipe_p, NIDL_PIPECTYPE, "interface reference");
if (!type_is_function(type_p)
&& FE_TEST(type_p->fe_info->flags, FE_HAS_PTR))
CHECKER_error(pipe_p, NIDL_PTRBASETYP);
if (type_p->xmit_as_type != NULL)
CHECKER_error(pipe_p, NIDL_XMITPIPEBASE);
if (type_p->kind == AST_void_k)
CHECKER_error(pipe_p, NIDL_VOIDOPPTR);
if (!AST_LOCAL_SET(int_p)
&& type_p->xmit_as_type == NULL
&& type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind == AST_void_k
&& !AST_CONTEXT_RD_SET(type_p)
)
CHECKER_error(pipe_p, NIDL_PTRVOIDCTX);
CHK_pipe_base_type_cs(pipe_p, int_p);
}
static void pipe_check
(
AST_pipe_n_t *pipe_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
if (type_p->xmit_as_type != NULL)
CHECKER_error(pipe_p, NIDL_PIPEXMITAS);
if (type_p->name == NAMETABLE_NIL_ID)
CHECKER_error(pipe_p, NIDL_ANONPIPE);
pipe_base_type(pipe_p, int_p);
}
static void enum_check
(
AST_enumeration_n_t *enum_p,
AST_type_n_t *type_p
)
{
if (type_is_anonymous(type_p))
CHECKER_warning(enum_p, NIDL_NOPORTANON, "enum");
}
static void clabel_value
(
AST_case_label_n_t *clabel_p,
AST_type_n_t *type_p
)
{
AST_constant_n_t *const_p;
if (clabel_p->default_label)
return;
const_p = clabel_p->value;
if (!const_is_integer(const_p)
&& !const_is_enum(const_p)
&& const_p->kind != AST_boolean_const_k
&& const_p->kind != AST_char_const_k)
{
CHECKER_error(clabel_p, NIDL_INVCASETYP);
return;
}
if ((type_is_integer(type_p)
&& !const_is_integer(const_p))
|| (type_is_enum(type_p)
&& !const_is_enum(const_p))
|| (type_p->kind == AST_boolean_k
&& const_p->kind != AST_boolean_const_k)
|| (type_p->kind == AST_character_k
&& const_p->kind != AST_char_const_k))
{
CHECKER_error(clabel_p, NIDL_CASEDISCTYPE);
return;
}
if (type_is_enum(type_p))
{
char const *clabel_name;
char const *econst_name;
AST_enumeration_n_t *enum_p;
AST_constant_n_t *econst_p;
NAMETABLE_id_to_string(const_p->name, &clabel_name);
if (clabel_name == NULL)
return;
enum_p = type_p->type_structure.enumeration;
econst_p = enum_p->enum_constants;
while (econst_p != NULL)
{
NAMETABLE_id_to_string(econst_p->name, &econst_name);
if (econst_name == NULL)
continue;
if (strcmp(clabel_name, econst_name) == 0)
return;
econst_p = econst_p->next;
}
CHECKER_error(clabel_p, NIDL_CASECONENUM);
}
}
static void clabel_check
(
AST_case_label_n_t *clabel_p,
AST_type_n_t *type_p
)
{
clabel_value(clabel_p, type_p);
}
static void arm_type
(
AST_arm_n_t *arm_p,
AST_interface_n_t *int_p
)
{
AST_type_n_t *type_p;
type_p = arm_p->type;
if (type_p == NULL)
return;
if (type_is_anonymous(type_p))
type_check(type_p, (ASTP_node_t *)arm_p, int_p);
if (type_p->xmit_as_type != NULL
&&
(AST_STRING_SET(arm_p)
|| AST_STRING0_SET(arm_p)
|| AST_UNIQUE_SET(arm_p)
|| AST_REF_SET(arm_p)
|| AST_SMALL_SET(arm_p)
|| AST_CONTEXT_SET(arm_p)
|| AST_PTR_SET(arm_p)))
CHECKER_error(arm_p, NIDL_XMITTYPEATTRS);
type_p = type_xmit_type(type_p);
#ifdef notdef
if (AST_CONFORMANT_SET(type_p))
CHECKER_error(arm_p, NIDL_CFMTUNION);
#endif
if (type_p->kind == AST_interface_k) {
char const * id_name;
NAMETABLE_id_to_string(type_p->name, &id_name);
CHECKER_error(arm_p, NIDL_INTREFNOTALO, id_name);
}
if (type_p->kind == AST_pipe_k)
CHECKER_error(arm_p, NIDL_PIPEUNIMEM);
if (AST_CONTEXT_RD_SET(type_p)
|| AST_CONTEXT_SET(arm_p))
CHECKER_error(arm_p, NIDL_CTXUNIMEM);
if (!AST_LOCAL_SET(int_p)
&& type_is_function(type_p))
#if 0
&& type_p->xmit_as_type == NULL)
#endif
CHECKER_error(arm_p, NIDL_FPUNIMEM);
if (type_p->kind == AST_handle_k)
#if 0
&& type_p->xmit_as_type == NULL)
#endif
CHECKER_error(arm_p, NIDL_HANUNIMEM);
if (type_p->kind == AST_void_k)
CHECKER_error(arm_p, NIDL_VOIDOPPTR);
if (!AST_LOCAL_SET(int_p)
#if 0
&& type_p->xmit_as_type == NULL
#endif
&& type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind == AST_void_k
&& !AST_CONTEXT_RD_SET(type_p)
&& !AST_CONTEXT_SET(arm_p)
)
CHECKER_error(arm_p, NIDL_PTRVOIDCTX);
if (FE_TEST(arm_p->fe_info->flags, FE_HAS_V1_ATTR)
&& FE_TEST(arm_p->fe_info->flags, FE_HAS_V2_ATTR)
&& ! ( FE_TEST(type_p->fe_info->flags, FE_HAS_V1_ATTR)
&& FE_TEST(type_p->fe_info->flags, FE_HAS_V2_ATTR) ))
CHECKER_warning(arm_p, NIDL_INCOMPATV1);
}
static void arm_string
(
AST_arm_n_t *arm_p
)
{
AST_type_n_t *type_p;
type_p = arm_p->type;
if (type_p == NULL)
return;
if (AST_STRING0_SET(arm_p)
&& !type_is_v1_string(type_p))
CHECKER_error(arm_p, NIDL_STRV1FIXED);
if ((AST_STRING0_SET(arm_p) || AST_STRING0_SET(type_p))
&& !(AST_SMALL_SET(arm_p) || AST_SMALL_SET(type_p)))
CHECKER_error(arm_p, NIDL_STRV1ARRAY);
if ((AST_STRING_SET(arm_p) && AST_SMALL_SET(arm_p))
|| (AST_STRING_SET(arm_p) && AST_SMALL_SET(type_p))
|| (AST_STRING_SET(type_p) && AST_SMALL_SET(arm_p)))
CHECKER_error(arm_p, NIDL_STRARRAYV1);
if (AST_STRING_SET(arm_p)
&& !type_is_string(type_p))
CHECKER_error(arm_p, NIDL_STRCHARBYTE);
if ( (AST_STRING_SET(arm_p) || AST_STRING_SET(type_p))
&& (AST_STRING0_SET(arm_p) || AST_STRING0_SET(type_p)) )
{
ASTP_attr_flag_t attr1 = ASTP_STRING;
ASTP_attr_flag_t attr2 = ASTP_STRING0;
CHECKER_error(arm_p, NIDL_CONFLICTATTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)),
KEYWORDS_lookup_text(AST_attribute_to_token(&attr2)));
}
}
static void arm_pointer
(
AST_arm_n_t *arm_p,
AST_interface_n_t *int_p ATTRIBUTE_UNUSED
)
{
AST_type_n_t *type_p;
boolean pointer_attr_valid = FALSE;
type_p = arm_p->type;
if (type_p == NULL)
return;
type_p = type_xmit_type(type_p);
#ifdef nodef
if (FE_TEST(type_p->fe_info->flags, FE_HAS_REF_PTR) ||
AST_REF_SET(arm_p))
CHECKER_error(arm_p, NIDL_ARMREFPTR);
#endif
if (type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind != AST_void_k)
pointer_attr_valid = TRUE;
if (AST_REF_SET(arm_p) && !pointer_attr_valid)
CHECKER_error(arm_p, NIDL_REFATTRPTR);
#if 0
if (type_p->kind == AST_pointer_k && type_p->type_structure.pointer->pointee_type->kind == AST_interface_k
&& (AST_UNIQUE_SET(arm_p) || AST_REF_SET(arm_p) || AST_PTR_SET(arm_p)))
CHECKER_warning(arm_p, NIDL_PTRATTBIGN);
#endif
#ifdef notdef
if (FE_TEST(type_p->fe_info->flags, FE_HAS_UNIQUE_PTR) ||
AST_UNIQUE_SET(arm_p))
CHECKER_error(arm_p, NIDL_ARMUNIQUEPTR);
#endif
if (AST_UNIQUE_SET(arm_p) && !pointer_attr_valid)
CHECKER_error(arm_p, NIDL_UNIQATTRPTR);
if (AST_PTR_SET(arm_p) && !pointer_attr_valid)
CHECKER_error(arm_p, NIDL_PTRATTRPTR);
if (AST_UNIQUE_SET(arm_p)
&& (*(int *)cmd_val[opt_standard] <= opt_standard_dce_1_0))
CHECKER_warning(arm_p, NIDL_NOPORTUNIQUE, OPT_STD_EXTENDED);
if (type_p->kind == AST_array_k &&
(AST_REF_SET(arm_p) || AST_PTR_SET(arm_p) || AST_UNIQUE_SET(arm_p) ||
AST_REF_SET(type_p) || AST_PTR_SET(type_p) || AST_UNIQUE_SET(type_p)))
CHECKER_error(arm_p, NIDL_ARRPTRPRM);
}
static void arm_small
(
AST_arm_n_t *arm_p
)
{
AST_type_n_t *type_p;
AST_array_n_t *array_p;
type_p = arm_p->type;
if (type_p == NULL
|| !type_is_array_np(type_p))
return;
array_p = type_p->type_structure.array;
if (AST_SMALL_SET(arm_p)
&& array_is_large(array_p))
CHECKER_error(arm_p, NIDL_SMALLINV);
}
static void arm_context
(
AST_arm_n_t *arm_p
)
{
AST_type_n_t *type_p;
type_p = arm_p->type;
if (type_p == NULL)
return;
if (AST_CONTEXT_SET(arm_p)
&& (type_p->kind != AST_pointer_k
|| (type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind
!= AST_void_k)))
CHECKER_error(arm_p, NIDL_CTXPTRVOID);
if (AST_UNIQUE_SET(arm_p)
&& type_p->kind == AST_pointer_k
&& AST_CONTEXT_RD_SET(type_p->type_structure.pointer->pointee_type))
CHECKER_error(arm_p, NIDL_UNIQCTXHAN);
if (AST_PTR_SET(arm_p)
&& type_p->kind == AST_pointer_k
&& AST_CONTEXT_RD_SET(type_p->type_structure.pointer->pointee_type))
CHECKER_error(arm_p, NIDL_PTRCTXHAN);
}
static void arm_check
(
AST_arm_n_t *arm_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
AST_case_label_n_t *clabel_p;
arm_type(arm_p, int_p);
arm_string(arm_p);
arm_pointer(arm_p, int_p);
arm_small(arm_p);
arm_context(arm_p);
if (type_p == NULL) return;
clabel_p = arm_p->labels;
while (clabel_p != NULL)
{
clabel_check(clabel_p, type_p);
clabel_p = clabel_p->next;
}
}
static void union_discrim_type
(
AST_disc_union_n_t *union_p
)
{
AST_type_n_t *type_p;
type_p = union_p->discrim_type;
if (type_p == NULL) return;
if (!type_is_index(type_p)
&& !type_is_enum(type_p)
&& type_p->kind != AST_boolean_k
&& type_p->kind != AST_character_k)
CHECKER_error(union_p, NIDL_UNIDISCTYP);
}
static void union_case_labels
(
AST_disc_union_n_t *union_p
)
{
AST_arm_n_t *arm_p;
AST_case_label_n_t *clabel_p;
AST_arm_n_t *s_arm_p;
AST_case_label_n_t *s_clabel_p;
boolean dup;
arm_p = union_p->arms;
while (arm_p != NULL)
{
clabel_p = arm_p->labels;
while (clabel_p != NULL)
{
s_arm_p = arm_p->next;
while (s_arm_p != NULL)
{
s_clabel_p = s_arm_p->labels;
dup = FALSE;
while (s_clabel_p != NULL)
{
if (clabel_p->default_label && s_clabel_p->default_label)
dup = TRUE;
else if (clabel_p->value != NULL
&& s_clabel_p->value != NULL
&& clabel_p->value->kind == s_clabel_p->value->kind)
{
switch (clabel_p->value->kind)
{
case AST_nil_const_k:
break;
case AST_int_const_k:
dup = (clabel_p->value->value.int_val
== s_clabel_p->value->value.int_val);
break;
case AST_hyper_int_const_k:
dup = (clabel_p->value->value.hyper_int_val.high
== s_clabel_p->value->value.hyper_int_val.high
&&
clabel_p->value->value.hyper_int_val.low
== s_clabel_p->value->value.hyper_int_val.low);
break;
case AST_char_const_k:
dup = (clabel_p->value->value.char_val
== s_clabel_p->value->value.char_val);
break;
case AST_string_const_k:
break;
case AST_boolean_const_k:
dup = (clabel_p->value->value.boolean_val
== s_clabel_p->value->value.boolean_val);
break;
default:
error(NIDL_INTERNAL_ERROR, __FILE__, __LINE__);
}
}
if (dup)
{
CHECKER_error(s_clabel_p, NIDL_DUPCASEVAL);
break;
}
s_clabel_p = s_clabel_p->next;
}
if (dup)
break;
else
s_arm_p = s_arm_p->next;
}
clabel_p = clabel_p->next;
}
arm_p = arm_p->next;
}
}
static void union_check
(
AST_disc_union_n_t *union_p,
AST_interface_n_t *int_p
)
{
AST_arm_n_t *arm_p;
union_discrim_type(union_p);
union_case_labels(union_p);
if (union_p->discrim_name == NAMETABLE_NIL_ID
&& (*(int *)cmd_val[opt_standard] <= opt_standard_dce_1_0))
CHECKER_warning(union_p, NIDL_NOPORTNEU, OPT_STD_EXTENDED);
arm_p = union_p->arms;
while (arm_p != NULL)
{
arm_check(arm_p, union_p->discrim_type, int_p);
arm_p = arm_p->next;
}
}
static void type_name_len
(
AST_type_n_t *top_type_p,
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
char const *type_name;
int type_len;
int max_len;
if (!AST_LOCAL_SET(int_p)
&& top_type_p->name != NAMETABLE_NIL_ID
&& top_type_p->xmit_as_type != NULL)
{
NAMETABLE_id_to_string(top_type_p->name, &type_name);
if (type_name == NULL)
return;
type_len = strlen(type_name);
max_len = MAX_ID - strlen("_from_xmit");
if (type_len > max_len)
CHECKER_error(top_type_p, NIDL_MAXIDTYPTA, max_len);
}
if (type_p->name == NAMETABLE_NIL_ID)
return;
NAMETABLE_id_to_string(type_p->name, &type_name);
if (type_name == NULL)
return;
type_len = strlen(type_name);
max_len = MAX_ID - strlen("_unbind");
if (!AST_LOCAL_SET(int_p)
&& type_len > max_len
&& AST_HANDLE_SET(type_p))
CHECKER_error(type_p, NIDL_MAXIDTYPHAN, max_len);
max_len = MAX_ID - strlen("_rundown");
if (!AST_LOCAL_SET(int_p)
&& type_len > max_len
&& AST_CONTEXT_RD_SET(type_p))
CHECKER_error(type_p, NIDL_MAXIDTYPCH, max_len);
max_len = MAX_ID - strlen("_mr");
if (!AST_LOCAL_SET(int_p)
&& !AST_IN_VARYING_SET(type_p) && !AST_OUT_VARYING_SET(type_p)
&& type_len > max_len
&& FE_TEST(type_p->fe_info->flags,FE_POINTED_AT))
{
char const *file_name;
AST_type_n_t *ptr_type_p = type_p->fe_info->type_specific.pointer_type;
CHECKER_error(type_p, NIDL_MAXIDTYPPT, max_len);
STRTAB_str_to_string(ptr_type_p->fe_info->file, &file_name);
CHECKER_warning(type_p, NIDL_NAMEREFAT, file_name,
ptr_type_p->fe_info->source_line);
}
max_len = MAX_ID - strlen("_mrV");
if (!AST_LOCAL_SET(int_p)
&& (AST_IN_VARYING_SET(type_p) || AST_OUT_VARYING_SET(type_p))
&& type_len > max_len
&& FE_TEST(type_p->fe_info->flags,FE_POINTED_AT))
{
char const *file_name;
AST_type_n_t *ptr_type_p = type_p->fe_info->type_specific.pointer_type;
CHECKER_error(type_p, NIDL_MAXIDTYPPT, max_len);
STRTAB_str_to_string(ptr_type_p->fe_info->file, &file_name);
CHECKER_warning(type_p, NIDL_NAMEREFAT, file_name,
ptr_type_p->fe_info->source_line);
}
max_len = MAX_ID - strlen("_h");
if (!AST_LOCAL_SET(int_p)
&& type_len > max_len
&& type_p->kind == AST_pipe_k)
CHECKER_error(type_p, NIDL_MAXIDTYPPIPE, max_len);
max_len = MAX_ID - strlen("_from_local");
if (!AST_LOCAL_SET(int_p)
&& type_len > max_len
&& type_p->rep_as_type != NULL)
CHECKER_error(type_p, NIDL_MAXIDTYPRA, max_len);
max_len = MAX_ID - strlen("Omr");
if (!AST_LOCAL_SET(int_p)
&& !AST_IN_VARYING_SET(type_p) && !AST_OUT_VARYING_SET(type_p)
&& type_len > max_len
&& AST_OUT_OF_LINE_SET(type_p))
CHECKER_error(type_p, NIDL_MAXIDTYPOOL, max_len);
max_len = MAX_ID - strlen("OmrV");
if (!AST_LOCAL_SET(int_p)
&& (AST_IN_VARYING_SET(type_p) || AST_OUT_VARYING_SET(type_p))
&& type_len > max_len
&& AST_OUT_OF_LINE_SET(type_p))
CHECKER_error(type_p, NIDL_MAXIDTYPOOL, max_len);
}
static void type_in_line
(
AST_type_n_t *type_p
)
{
if (AST_IN_LINE_SET(type_p)
&& AST_OUT_OF_LINE_SET(type_p))
CHECKER_acf_error(type_p, NIDL_TYPLINEATTR);
if ((AST_IN_LINE_SET(type_p) || AST_OUT_OF_LINE_SET(type_p))
&& type_is_scalar(type_p))
{
char const *file_name;
char const *type_name;
STRTAB_str_to_string(type_p->fe_info->file, &file_name);
NAMETABLE_id_to_string(type_p->name, &type_name);
CHECKER_acf_warning(type_p, NIDL_LINENONSCAL);
CHECKER_acf_warning(type_p, NIDL_NAMEDECLAT, type_name, file_name,
type_p->fe_info->source_line);
}
}
static void type_string
(
AST_type_n_t *type_p
)
{
if (AST_STRING0_SET(type_p)
&& !type_is_v1_string(type_p))
CHECKER_error(type_p, NIDL_STRV1FIXED);
if (AST_STRING_SET(type_p) && AST_SMALL_SET(type_p))
CHECKER_error(type_p, NIDL_STRARRAYV1);
if (AST_STRING_SET(type_p)
&& !type_is_string(type_p))
CHECKER_error(type_p, NIDL_STRCHARBYTE);
if (AST_STRING_SET(type_p)
&& AST_STRING0_SET(type_p))
{
ASTP_attr_flag_t attr1 = ASTP_STRING;
ASTP_attr_flag_t attr2 = ASTP_STRING0;
CHECKER_error(type_p, NIDL_CONFLICTATTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)),
KEYWORDS_lookup_text(AST_attribute_to_token(&attr2)));
}
}
static void type_pointer
(
AST_type_n_t *type_p
)
{
boolean pointer_attr_valid = FALSE;
if (type_p->kind == AST_array_k
|| (type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind
!= AST_void_k))
pointer_attr_valid = TRUE;
if (AST_REF_SET(type_p) && !pointer_attr_valid)
CHECKER_error(type_p, NIDL_REFATTRPTR);
if (AST_UNIQUE_SET(type_p) && !pointer_attr_valid)
CHECKER_error(type_p, NIDL_UNIQATTRPTR);
#if 0
if (type_p->kind == AST_pointer_k && type_p->type_structure.pointer->pointee_type->kind == AST_interface_k
&& (AST_UNIQUE_SET(type_p) || AST_REF_SET(type_p) || AST_PTR_SET(type_p)))
CHECKER_warning(type_p, NIDL_PTRATTBIGN);
#endif
if (AST_PTR_SET(type_p) && !pointer_attr_valid)
CHECKER_error(type_p, NIDL_PTRATTRPTR);
if (AST_UNIQUE_SET(type_p)
&& (*(int *)cmd_val[opt_standard] <= opt_standard_dce_1_0))
CHECKER_warning(type_p, NIDL_NOPORTUNIQUE, OPT_STD_EXTENDED);
if (FE_TEST(type_p->fe_info->flags, FE_HAS_PTR_ARRAY))
CHECKER_error(type_p, NIDL_ARRPTRPRM);
#if 0
{
AST_type_n_t *top_type_p = type_p;
type_p = ASTP_chase_ptr_to_kind(type_p, AST_disc_union_k);
if (type_p != NULL
&& type_p->kind == AST_disc_union_k
&& type_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID
&& type_p->fe_info->pointer_count > 1)
CHECKER_error(top_type_p, NIDL_PTRNEUNION);
}
#endif
}
static void type_small
(
AST_type_n_t *type_p
)
{
AST_array_n_t *array_p;
if (AST_SMALL_SET(type_p)
&& type_p->kind == AST_pointer_k)
CHECKER_error(type_p, NIDL_SMALLARRSYN);
if (!type_is_array_np(type_p))
return;
array_p = type_p->type_structure.array;
if (AST_SMALL_SET(type_p)
&& AST_CONFORMANT_SET(type_p)
&& array_is_conformant_upper(array_p))
CHECKER_error(type_p, NIDL_SMALLMULTID);
if (AST_SMALL_SET(type_p)
&& array_is_large(array_p))
CHECKER_error(type_p, NIDL_SMALLINV);
if (AST_SMALL_SET(type_p)
&& AST_CONFORMANT_SET(type_p)
&& array_has_open_lb(array_p))
CHECKER_error(type_p, NIDL_SMALLOPENLB);
}
static void type_context
(
AST_type_n_t *type_p
)
{
if (AST_CONTEXT_RD_SET(type_p)
&& (type_p->kind != AST_pointer_k
|| (type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind
!= AST_void_k
&& !(type_p->type_structure.pointer->pointee_type->kind
== AST_structure_k
&& AST_DEF_AS_TAG_SET(type_p->type_structure.pointer->
pointee_type)))))
CHECKER_error(type_p, NIDL_CTXPTRVOID);
if (AST_UNIQUE_SET(type_p)
&& type_p->kind == AST_pointer_k
&& AST_CONTEXT_RD_SET(type_p->type_structure.pointer->pointee_type))
CHECKER_error(type_p, NIDL_UNIQCTXHAN);
if (AST_PTR_SET(type_p)
&& type_p->kind == AST_pointer_k
&& AST_CONTEXT_RD_SET(type_p->type_structure.pointer->pointee_type))
CHECKER_error(type_p, NIDL_PTRCTXHAN);
if (AST_HANDLE_SET(type_p)
&& type_p->kind == AST_pointer_k
&& type_p->type_structure.pointer->pointee_type->kind == AST_void_k)
{
ASTP_attr_flag_t attr1 = ASTP_HANDLE;
CHECKER_error(type_p, NIDL_ATTRPTRVOID,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)));
}
if (AST_HANDLE_SET(type_p)
&& type_p->kind == AST_handle_k)
CHECKER_error(type_p, NIDL_HANATTRTRAN);
if (AST_HANDLE_SET(type_p)
&& type_p->rep_as_type != NULL)
{
ASTP_attr_flag_t attr1 = ASTP_HANDLE;
CHECKER_error(type_p, NIDL_CONFLICTATTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)),
"represent_as");
}
}
static void type_conformant
(
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
AST_array_n_t *array_p;
if (!type_is_array_np(type_p))
return;
array_p = type_p->type_structure.array;
if (!AST_LOCAL_SET(int_p)
&& AST_CONFORMANT_SET(type_p)
&& array_is_conformant_upper(array_p)
&& (*(int *)cmd_val[opt_standard] <= opt_standard_dce_1_0))
CHECKER_warning(type_p, NIDL_NOPORTCFMT, OPT_STD_EXTENDED);
}
static void type_ignore
(
AST_type_n_t *type_p
)
{
if (AST_IGNORE_SET(type_p)
&& type_p->kind != AST_pointer_k)
CHECKER_error(type_p, NIDL_IGNATTRPTR);
}
static void type_switch_type
(
AST_type_n_t *type_p
)
{
if (type_p->kind == AST_disc_union_k
&& type_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID
&& type_p->type_structure.disc_union->discrim_type == NULL)
CHECKER_error(type_p, NIDL_NEUSWTYPE);
}
static void type_transmit_as
(
AST_type_n_t *top_type_p,
AST_type_n_t *type_p
)
{
if (top_type_p->xmit_as_type == NULL)
return;
if (AST_CONFORMANT_SET(type_p)
&& !AST_STRING_SET(type_p)
&& type_is_array(type_p))
CHECKER_error(top_type_p, NIDL_XMITCFMTARR);
if (AST_CONFORMANT_SET(top_type_p->xmit_as_type)
&& !AST_STRING_SET(top_type_p->xmit_as_type)
&& type_is_array(top_type_p->xmit_as_type))
CHECKER_error(top_type_p, NIDL_XMITCFMTARR);
if (AST_CONFORMANT_SET(top_type_p)
&& top_type_p->kind == AST_structure_k)
CHECKER_error(top_type_p, NIDL_STRUCTXMITCFMT);
if (FE_TEST(type_p->fe_info->flags, FE_HAS_REF_PTR))
{
ASTP_attr_flag_t attr = ASTP_REF;
CHECKER_error(type_p, NIDL_XMITPTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr)));
}
if (FE_TEST(type_p->fe_info->flags, FE_HAS_FULL_PTR))
{
ASTP_attr_flag_t attr = ASTP_PTR;
CHECKER_error(type_p, NIDL_XMITPTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr)));
}
if (FE_TEST(type_p->fe_info->flags, FE_HAS_UNIQUE_PTR))
{
ASTP_attr_flag_t attr = ASTP_UNIQUE;
CHECKER_error(type_p, NIDL_XMITPTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr)));
}
if (type_p->rep_as_type != NULL)
CHECKER_error(type_p, NIDL_XMITASREP);
if (AST_STRING_SET(top_type_p)
|| AST_STRING0_SET(top_type_p)
|| AST_UNIQUE_SET(top_type_p)
|| AST_REF_SET(top_type_p)
|| AST_IGNORE_SET(top_type_p)
|| AST_SMALL_SET(top_type_p)
|| AST_CONTEXT_RD_SET(top_type_p)
|| AST_PTR_SET(top_type_p))
CHECKER_error(top_type_p, NIDL_XMITTYPEATTRS);
if (type_p->kind == AST_disc_union_k
&& type_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID)
CHECKER_error(top_type_p, NIDL_NEUXMITAS);
if (top_type_p->kind == AST_disc_union_k
&& top_type_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID)
CHECKER_error(top_type_p, NIDL_NEUXMITYPE);
}
static void type_represent_as
(
AST_type_n_t *type_p,
AST_interface_n_t *int_p
)
{
if (type_p->rep_as_type == NULL)
return;
if (AST_CONFORMANT_SET(type_p))
CHECKER_error(type_p, NIDL_TYPEREPCFMT);
if (FE_TEST(type_p->fe_info->flags, FE_HAS_REF_PTR))
{
ASTP_attr_flag_t attr = ASTP_REF;
CHECKER_error(type_p, NIDL_XMITPTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr)));
}
if (FE_TEST(type_p->fe_info->flags, FE_HAS_FULL_PTR))
{
ASTP_attr_flag_t attr = ASTP_PTR;
CHECKER_error(type_p, NIDL_XMITPTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr)));
}
if (FE_TEST(type_p->fe_info->flags, FE_HAS_UNIQUE_PTR))
{
ASTP_attr_flag_t attr = ASTP_UNIQUE;
CHECKER_error(type_p, NIDL_XMITPTR,
KEYWORDS_lookup_text(AST_attribute_to_token(&attr)));
}
if (int_p->includes == NULL
&& ASTP_lookup_binding(null_parser_location,
type_p->rep_as_type->type_name,
fe_type_n_k, FALSE) == NULL)
{
char const*id_name;
NAMETABLE_id_to_string(type_p->rep_as_type->type_name, &id_name);
CHECKER_acf_warning(type_p, NIDL_INCLTYPE, id_name);
}
{
AST_type_n_t *rep_type_p = (AST_type_n_t *)
ASTP_lookup_binding(null_parser_location,
type_p->rep_as_type->type_name, fe_type_n_k, FALSE);
if (rep_type_p != NULL
&& rep_type_p->kind == AST_disc_union_k
&& rep_type_p->type_structure.disc_union->discrim_name
== NAMETABLE_NIL_ID)
CHECKER_acf_error(type_p, NIDL_NEUREPAS);
}
if (type_p->kind == AST_disc_union_k
&& type_p->type_structure.disc_union->discrim_name == NAMETABLE_NIL_ID)
CHECKER_acf_error(type_p, NIDL_NEUREPTYPE);
}
static void type_check
(
AST_type_n_t *type_p,
ASTP_node_t *node_p,
AST_interface_n_t *int_p
)
{
AST_type_n_t *xmit_type_p;
char const * id_name;
xmit_type_p = type_xmit_type(type_p);
if (!AST_LOCAL_SET(int_p))
type_name_len(type_p, xmit_type_p, int_p);
type_in_line(xmit_type_p);
type_string(xmit_type_p);
type_pointer(xmit_type_p);
type_small(xmit_type_p);
type_context(xmit_type_p);
type_conformant(xmit_type_p, int_p);
type_ignore(xmit_type_p);
type_switch_type(xmit_type_p);
type_transmit_as(type_p, xmit_type_p);
type_represent_as(xmit_type_p, int_p);
CHK_type_cs(type_p, xmit_type_p, int_p);
if (FE_TEST(type_p->fe_info->flags, FE_HAS_V1_ATTR)
&& FE_TEST(type_p->fe_info->flags, FE_HAS_V2_ATTR))
CHECKER_warning(type_p, NIDL_INCOMPATV1);
switch (type_p->kind)
{
case AST_handle_k:
case AST_boolean_k:
case AST_byte_k:
case AST_character_k:
case AST_small_integer_k:
case AST_short_integer_k:
case AST_long_integer_k:
case AST_hyper_integer_k:
case AST_small_unsigned_k:
case AST_short_unsigned_k:
case AST_long_unsigned_k:
case AST_hyper_unsigned_k:
case AST_short_float_k:
case AST_long_float_k:
case AST_void_k:
break;
case AST_enum_k:
enum_check(type_p->type_structure.enumeration, type_p);
break;
case AST_array_k:
array_check((ASTP_node_t *)type_p->type_structure.array,
type_p,
node_p,
type_p->type_structure.array->element_type,
int_p,
false);
break;
case AST_structure_k:
struct_check(type_p->type_structure.structure, int_p);
break;
case AST_pipe_k:
pipe_check(type_p->type_structure.pipe, type_p, int_p);
break;
case AST_pointer_k:
ptr_check(type_p->type_structure.pointer, type_p, node_p, int_p);
break;
case AST_function_k:
if (!AST_LOCAL_SET(int_p))
CHECKER_error(type_p, NIDL_FUNTYPDCL);
break;
case AST_disc_union_k:
union_check(type_p->type_structure.disc_union, int_p);
break;
case AST_interface_k:
NAMETABLE_id_to_string(type_p->name, &id_name);
CHECKER_error(type_p, NIDL_INTREFNOTALO, id_name);
break;
default:
error(NIDL_INTERNAL_ERROR, __FILE__, __LINE__);
}
}
static void constant_check
(
AST_constant_n_t *const_p ATTRIBUTE_UNUSED
)
{
}
static void export_check
(
AST_export_n_t *export_p,
AST_interface_n_t *int_p,
AST_interface_n_t *parent_int_p
)
{
switch (export_p->kind)
{
case AST_cpp_quote_k:
break;
case AST_constant_k:
constant_check(export_p->thing_p.exported_constant);
break;
case AST_operation_k:
if (parent_int_p == NULL)
operation_check(export_p->thing_p.exported_operation, int_p);
break;
case AST_type_k:
type_check(export_p->thing_p.exported_type, (ASTP_node_t *)export_p,
int_p);
break;
default:
error(NIDL_INTERNAL_ERROR, __FILE__, __LINE__);
}
}
static void int_name_len
(
AST_interface_n_t *int_p
)
{
char const *int_name;
unsigned int max_len;
NAMETABLE_id_to_string(int_p->name, &int_name);
if (int_name == NULL)
return;
max_len = MAX_ID - strlen("_v#_#_c_ifspec");
if (strlen(int_name) > max_len)
CHECKER_error(int_p, NIDL_MAXIDINTF, max_len);
}
static void int_in_line
(
AST_interface_n_t *int_p
)
{
if (AST_IN_LINE_SET(int_p)
&& AST_OUT_OF_LINE_SET(int_p))
CHECKER_acf_error(int_p, NIDL_INTLINEATTR);
}
static void int_code
(
AST_interface_n_t *int_p,
AST_interface_n_t *parent_int_p
)
{
if (AST_CODE_SET(int_p)
&& AST_NO_CODE_SET(int_p))
CHECKER_acf_error(int_p, NIDL_INTCODEATTR);
if (parent_int_p == NULL
&& AST_NO_CODE_SET(int_p)
&& cmd_opt[opt_emit_sstub]
&& !cmd_opt[opt_emit_cstub])
CHECKER_acf_warning(int_p, NIDL_SRVNOCODE);
if (parent_int_p == NULL
&& int_p->op_count > 0)
{
AST_export_n_t *export_p;
boolean code_op = FALSE;
for (export_p = int_p->exports; export_p; export_p = export_p->next)
{
if (export_p->kind != AST_operation_k) continue;
if (AST_CODE_SET(export_p->thing_p.exported_operation))
{
code_op = TRUE;
break;
}
}
if (!code_op)
CHECKER_acf_warning(int_p, NIDL_NOCODEOPS);
}
}
static void int_handle
(
AST_interface_n_t *int_p
)
{
if (int_p->implicit_handle_name != NAMETABLE_NIL_ID
&& AST_AUTO_HANDLE_SET(int_p))
CHECKER_acf_error(int_p, NIDL_CONFHANATTR);
if (int_p->implicit_handle_name != NAMETABLE_NIL_ID
&& int_p->implicit_handle_type != NULL
&& !type_is_handle(int_p->implicit_handle_type))
CHECKER_acf_error(int_p, NIDL_IMPHANVAR);
}
static void int_local
(
AST_interface_n_t *int_p,
AST_interface_n_t *parent_int_p
)
{
boolean uuid_null;
uuid_null = uuid_is_null(&int_p->uuid);
if (AST_LOCAL_SET(int_p)
&& !uuid_null && !AST_OBJECT_SET(int_p))
CHECKER_error(int_p, NIDL_UUIDINV);
if (!AST_LOCAL_SET(int_p)
&& parent_int_p != NULL
&& AST_LOCAL_SET(parent_int_p))
AST_SET_LOCAL(int_p);
if (!AST_LOCAL_SET(int_p)
&& uuid_null
&& parent_int_p == NULL
&& int_p->op_count != 0)
CHECKER_error(int_p, NIDL_INTUUIDREQ);
if (parent_int_p != NULL
&& !AST_LOCAL_SET(parent_int_p)
&& AST_LOCAL_SET(int_p))
CHECKER_error(int_p, NIDL_IMPORTLOCAL);
}
static void int_inherit(AST_interface_n_t * int_p)
{
char const * id_name;
if (int_p->inherited_interface_name != NAMETABLE_NIL_ID) {
if (!NAMETABLE_lookup_local(int_p->inherited_interface_name)) {
NAMETABLE_id_to_string(int_p->inherited_interface_name, &id_name);
}
}
}
static void interface_check
(
AST_interface_n_t *int_p,
AST_interface_n_t *parent_int_p
)
{
AST_export_n_t *export_p;
AST_import_n_t *import_p;
int_name_len(int_p);
int_in_line(int_p);
int_code(int_p, parent_int_p);
int_handle(int_p);
int_local(int_p, parent_int_p);
int_inherit(int_p);
import_p = int_p->imports;
while (import_p != NULL)
{
if (import_p->interface != NULL)
interface_check(import_p->interface, int_p);
import_p = import_p->next;
}
export_p = int_p->exports;
while (export_p != NULL)
{
export_check(export_p, int_p, parent_int_p);
export_p = export_p->next;
}
if (parent_int_p == NULL)
{
AST_type_p_n_t *typep_p;
AST_type_n_t *type_p;
for (typep_p = int_p->pa_types
; typep_p != NULL
; typep_p = typep_p->next)
{
type_p = typep_p->type;
if (type_p->kind == AST_enum_k
&& AST_V1_ENUM_SET(type_p))
CHECKER_error(type_p, NIDL_PTRV1ENUM);
}
if (int_p->exceptions != NULL
&& (*(int *)cmd_val[opt_standard] < opt_standard_dce_1_1))
CHECKER_warning(int_p, NIDL_NOPORTATTR,
"exceptions", OPT_STD_EXTENDED);
}
if (AST_OBJECT_SET(int_p) && ASTP_IF_AF_SET(int_p, ASTP_IF_VERSION)) {
CHECKER_warning(int_p, NIDL_CONFLICTATTR, "version", "object");
}
if (!AST_OBJECT_SET(int_p) && int_p->inherited_interface_name != NAMETABLE_NIL_ID) {
CHECKER_warning(int_p, NIDL_ANCREQSOBJ);
}
}
boolean CHECKER_main
(
boolean *cmd_opt_arr,
void **cmd_val_arr,
AST_interface_n_t *int_p
)
{
cmd_opt = cmd_opt_arr;
cmd_val = cmd_val_arr;
interface_check(int_p, NULL);
if (def_auto_handle > 0)
AST_SET_AUTO_HANDLE(int_p);
return (error_count == 0);
}
void CHECKER_error
(
void *in_node_p,
long msgid,
...
)
{
ASTP_node_t *node_p = in_node_p;
va_list arglist;
va_start (arglist, msgid);
vlog_source_error(node_p->fe_info->file,
node_p->fe_info->source_line,
msgid, arglist);
va_end (arglist);
}
void CHECKER_warning
(
void *in_node_p,
long msgid,
...
)
{
ASTP_node_t *node_p = in_node_p;
va_list arglist;
va_start (arglist, msgid);
vlog_source_warning(node_p->fe_info->file,
node_p->fe_info->source_line,
msgid, arglist);
va_end (arglist);
}
void CHECKER_acf_error
(
void *in_node_p,
long msgid,
...
)
{
ASTP_node_t *node_p = in_node_p;
va_list arglist;
va_start (arglist, msgid);
if (node_p->fe_info->acf_file != (STRTAB_str_t)0)
{
vlog_source_error(node_p->fe_info->acf_file,
node_p->fe_info->acf_source_line,
msgid, arglist);
}
else
{
vlog_source_error(node_p->fe_info->file,
node_p->fe_info->source_line,
msgid, arglist);
}
va_end (arglist);
}
void CHECKER_acf_warning
(
void *in_node_p,
long msgid,
...
)
{
ASTP_node_t *node_p = in_node_p;
va_list arglist;
va_start (arglist, msgid);
if (node_p->fe_info->acf_file != (STRTAB_str_t)0)
vlog_source_warning(node_p->fe_info->acf_file,
node_p->fe_info->acf_source_line,
msgid, arglist);
else
vlog_source_warning(node_p->fe_info->file,
node_p->fe_info->source_line,
msgid, arglist);
va_end (arglist);
}
boolean type_is_base
(
AST_type_n_t *type_p
)
{
return ((type_p) == ASTP_char_ptr
|| (type_p) == ASTP_boolean_ptr
|| (type_p) == ASTP_byte_ptr
|| (type_p) == ASTP_void_ptr
|| (type_p) == ASTP_handle_ptr
|| (type_p) == ASTP_short_float_ptr
|| (type_p) == ASTP_long_float_ptr
|| (type_p) == ASTP_small_int_ptr
|| (type_p) == ASTP_short_int_ptr
|| (type_p) == ASTP_long_int_ptr
|| (type_p) == ASTP_hyper_int_ptr
|| (type_p) == ASTP_small_unsigned_ptr
|| (type_p) == ASTP_short_unsigned_ptr
|| (type_p) == ASTP_long_unsigned_ptr
|| (type_p) == ASTP_hyper_unsigned_ptr);
}