// buffer of function pointers with size `size` is allowed
void(**fn_ptr)(void)__sized_by_or_null(size);
};
structon_member_pointer_fn_ptr_ty_ptr_ty{
intsize;
// buffer of function pointers with size `size` is allowed
fn_ptr_ty*fn_ptr__sized_by_or_null(size);
};
structon_member_pointer_fn_ty{
intsize;
// buffer of functions with size `size` is allowed
// expected-error@+1{{'sized_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'void (void)' is a function type}}
void(*fn_ptr)(void)__sized_by_or_null(size);
};
structon_member_pointer_fn_ptr_ty_ty{
intsize;
// buffer of functions with size `size` is allowed
// expected-error@+1{{'sized_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'void (void)' is a function type}}
fn_ptr_tyfn_ptr__sized_by_or_null(size);
};
structhas_unannotated_vla{
intcount;
intbuffer[];
};
structon_member_pointer_struct_with_vla{
intsize;
// we know the size so this is fine for tracking size, however indexing would be an issue
// expected-error@+1{{'sized_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'struct has_unannotated_vla' is a struct type with a flexible array member}}
// we know the size so this is fine for tracking size, however indexing would be an issue
// expected-error@+1{{'sized_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'struct has_annotated_vla' is a struct type with a flexible array member}}
// expected-error@+1{{'sized_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'void (void)' is a function type}}
void(*__sized_by_or_null(size)fn_ptr)(void);
};
structon_member_pointer_fn_ptr_ty_ty_pos{
intsize;
// expected-error@+1{{'sized_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'void (void)' is a function type}}
fn_ptr_ty__sized_by_or_null(size)fn_ptr;
};
// TODO: This should be forbidden but isn't due to sized_by_or_null being treated
// as a declaration attribute.
structon_member_pointer_fn_ptr_ty_ty_pos_inner{
intsize;
void(*__sized_by_or_null(size)*fn_ptr)(void);
};
structon_member_pointer_struct_with_vla_ty_pos{
intsize;
// expected-error@+1{{'sized_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'struct has_unannotated_vla' is a struct type with a flexible array member}}
// expected-error@+1{{'sized_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'struct has_annotated_vla' is a struct type with a flexible array member}}