Open
Description
This issue was copied from checkedc/checkedc-clang#649
Question: If Checked C supports safe function pointers in itype
, then what is the correct syntax?
@Machiry and I have been trying to create a function pointer with itype
.
As you can see from our example below the first two functions wild_func_ptr()
and checkedc_func_ptr()
will compile with no errors. When the itype
is introduced in itype_func()
and itype_ptr_func()
the compiler will raise errors.
ityf.c
:
int wild_func_ptr(int (*f)(int)) {
return 0;
}
int checkedc_func_ptr(_Ptr<int (int)> f) {
return 0;
}
// function pointer returning int
int itype_func(int (*f)(int) : itype(_Ptr<int (int)>)) {
return 0;
}
// function pointer that returns a pointer.
int itype_ptr_func(int *(*f)(int) : itype(_Ptr<_Ptr<int> (int)>)) {
return 0;
}
$ cclang -c ityf.c
:
ityf.c:9:32: error: interface type only allowed for a pointer return type
int itype_func(int (*f)(int) : itype(_Ptr<int (int)>)) {
^
ityf.c:13:43: error: mismatch between interface type '_Ptr<_Ptr<int> (int)>' and declared type 'int *'
int itype_ptr_func(int *(*f)(int) : itype(_Ptr<_Ptr<int> (int)>)) {
^
2 errors generated.