Commit 48177ec6 authored by Stefan Behnel's avatar Stefan Behnel

fix ticket #643: infer the type of C function names as function pointers

parent 59921a82
......@@ -1296,6 +1296,9 @@ class NameNode(AtomicExprNode):
# Unfortunately the type attribute of type objects
# is used for the pointer to the type they represent.
return type_type
elif self.entry.type.is_cfunction:
# special case: referring to a C function must return it's pointer
return PyrexTypes.CPtrType(self.entry.type)
else:
return self.entry.type
......
......@@ -199,6 +199,17 @@ def builtin_type_operations():
T2 = () * 2
assert typeof(T2) == "tuple object", typeof(T2)
cdef int func(int x):
return x+1
def c_functions():
"""
>>> c_functions()
"""
f = func
assert typeof(f) == 'int (*)(int)', typeof(f)
assert 2 == f(1)
def cascade():
"""
>>> cascade()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment