struct A {};
typedef struct A *MPI_Datatype;
int wrong1(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag ));
int wrong2(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,0,7) ));
int wrong3(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,3,7) ));
int wrong4(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,1,0) ));
int wrong5(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,1,3) ));
int wrong6(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,0x8000000000000001ULL,1) ));
extern int x;
int wrong7(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,x,2) ));
int wrong8(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,1,x) ));
int wrong9 __attribute__(( pointer_with_type_tag(mpi,1,2) ));
int wrong10(double buf, MPI_Datatype type)
__attribute__(( pointer_with_type_tag(mpi,1,2) ));
int ok11(void *, ...)
__attribute__(( pointer_with_type_tag(mpi,1,2) ));
int wrong11(void *, ...)
__attribute__(( pointer_with_type_tag(mpi,2,3) ));
extern struct A datatype_wrong1
__attribute__(( type_tag_for_datatype ));
extern struct A datatype_wrong2
__attribute__(( type_tag_for_datatype(mpi,1,2) ));
extern struct A datatype_wrong3
__attribute__(( type_tag_for_datatype(mpi,not_a_type) ));
extern struct A datatype_wrong4
__attribute__(( type_tag_for_datatype(mpi,int,int) ));
extern struct A datatype_wrong5
__attribute__(( type_tag_for_datatype(mpi,int,not_a_flag) ));
extern struct A datatype_wrong6
__attribute__(( type_tag_for_datatype(mpi,int,layout_compatible,not_a_flag) ));
void datatype_wrong7(void) __attribute__((type_tag_for_datatype(datatype_wrong7, int)));
void A_func(void *ptr, void *tag) __attribute__(( pointer_with_type_tag(a,1,2) ));
extern struct A A_tag __attribute__(( type_tag_for_datatype(a,int) ));
extern struct A B_tag __attribute__(( type_tag_for_datatype(b,int) ));
void C_func(void *ptr, int tag) __attribute__(( pointer_with_type_tag(c,1,2) ));
static const int C_tag __attribute__(( type_tag_for_datatype(c,int) )) = 10;
static const int D_tag __attribute__(( type_tag_for_datatype(d,int) )) = 20;
void test_tag_mismatch(int *ptr)
{
A_func(ptr, &A_tag); A_func(ptr, &B_tag); C_func(ptr, C_tag); C_func(ptr, D_tag); C_func(ptr, 10); C_func(ptr, 20); }
void test_null_pointer(void)
{
C_func(0, C_tag); C_func((void *) 0, C_tag); C_func((int *) 0, C_tag); C_func((long *) 0, C_tag); }
void E_func(void *ptr, int tag) __attribute__(( pointer_with_type_tag(e,1,2) ));
typedef char E_char;
typedef char E_char_2;
typedef signed char E_char_signed;
typedef unsigned char E_char_unsigned;
static const int E_tag __attribute__(( type_tag_for_datatype(e,E_char) )) = 10;
void test_char_typedef(char *char_buf,
E_char_2 *e_char_buf,
E_char_signed *e_char_signed_buf,
E_char_unsigned *e_char_unsigned_buf)
{
E_func(char_buf, E_tag);
E_func(e_char_buf, E_tag);
#ifdef __CHAR_UNSIGNED__
E_func(e_char_signed_buf, E_tag); E_func(e_char_unsigned_buf, E_tag);
#else
E_func(e_char_signed_buf, E_tag);
E_func(e_char_unsigned_buf, E_tag); #endif
}
#define F_DUPFD 10
#define F_SETLK 20
struct flock { };
static const int F_DUPFD_tag __attribute__(( type_tag_for_datatype(fcntl,int) )) = F_DUPFD;
static const int F_SETLK_tag __attribute__(( type_tag_for_datatype(fcntl,struct flock *) )) = F_SETLK;
int fcntl(int fd, int cmd, ...) __attribute__(( argument_with_type_tag(fcntl,3,2) ));
void test_argument_with_type_tag(struct flock *f)
{
fcntl(0, F_DUPFD, 10); fcntl(0, F_SETLK, f);
fcntl(0, F_SETLK, 10); fcntl(0, F_DUPFD, f); }
void test_tag_expresssion(int b) {
fcntl(0, b ? F_DUPFD : F_SETLK, 10); fcntl(0, b + F_DUPFD, 10); fcntl(0, (b, F_DUPFD), 10); }
void F_func(void *ptr, unsigned long long tag) __attribute__((pointer_with_type_tag(f,1,2) ));
static const unsigned long long F_tag1 __attribute__(( type_tag_for_datatype(f,int) )) = 0xFFFFFFFFFFFFFFFFULL;
static const unsigned long long F_tag2 __attribute__(( type_tag_for_datatype(f,float) )) = 0xFFFFFFFFULL;
void test_64bit_magic(int *int_ptr, float *float_ptr)
{
F_func(int_ptr, 0xFFFFFFFFFFFFFFFFULL);
F_func(int_ptr, 0xFFFFFFFFULL); F_func(float_ptr, 0xFFFFFFFFFFFFFFFFULL); F_func(float_ptr, 0xFFFFFFFFULL);
}