merged in Vitek's generators branch
[cython.git] / tests / errors / e_cstruct.pyx
1 # mode: error
2
3 cdef struct Spam:
4         int i
5         char c
6         float *p[42]
7         obj             # error - py object
8
9 #cdef struct Spam: # error - redefined (not an error in Cython, should it be?)
10 #       int j
11
12 cdef struct Grail
13
14 cdef void eggs(Spam s):
15         cdef int j
16         cdef Grail *gp
17         j = s.k # error - undef attribute
18         j = s.p # type error
19         s.p = j # type error
20         j = j.i # no error - coercion to Python object
21         j.i = j # no error - coercion to Python object
22         j = gp.x # error - incomplete type
23         gp.x = j # error - incomplete type
24
25
26 _ERRORS = u"""
27 5:36: C struct/union member cannot be a Python object
28 15:6: Object of type 'Spam' has no attribute 'k'
29 16:6: Cannot assign type 'float *[42]' to 'int'
30 17:21: Cannot assign type 'int' to 'float *[42]'
31 20:7: Cannot select attribute of incomplete type 'Grail'
32 21:3: Cannot select attribute of incomplete type 'Grail'
33 """