summaryrefslogtreecommitdiff
path: root/tests/run/cpp_class_redef.pyx
blob: 36cd8ea04659b5f1dd3cfe58e35c32c958e5ba56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# mode: run
# tag: cpp, warnings, no-cpp-locals

# This gives a warning about the previous .pxd definition, but should not give an error.
cdef cppclass Foo:
    int _foo
    int get_foo():
        return this._foo
    void set_foo(int foo):
        this._foo = foo

def test_Foo(n):
    """
    >>> test_Foo(1)
    1
    """
    cdef Foo* foo = NULL
    try:
        foo = new Foo()
        foo.set_foo(n)
        return foo.get_foo()
    finally:
        del foo


_WARNINGS = """
5:5: 'Foo' already defined  (ignoring second definition)
"""