Commit 4a57c2c3 authored by Stefan Behnel's avatar Stefan Behnel

declare C++ default constructor 'except +', fix constructor declarations in test

parent 66204a91
......@@ -1329,7 +1329,7 @@ class NewExprNode(AtomicExprNode):
self.cpp_check(env)
constructor = type.scope.lookup(u'<init>')
if constructor is None:
return_type = PyrexTypes.CFuncType(type, [])
return_type = PyrexTypes.CFuncType(type, [], exception_check='+')
return_type = PyrexTypes.CPtrType(return_type)
type.scope.declare_cfunction(u'<init>', return_type, self.pos)
constructor = type.scope.lookup(u'<init>')
......
......@@ -7,19 +7,19 @@ cdef extern from "shapes.h" namespace "shapes":
cdef cppclass Circle(Shape):
int radius
Circle(int)
Circle(int) except +
cdef cppclass Rectangle(Shape):
int width
int height
Rectangle()
Rectangle(int, int)
Rectangle() except +
Rectangle(int, int) except +
int method(int)
int method(bint)
cdef cppclass Square(Rectangle):
int side
Square(int)
Square(int) except +
cdef cppclass Empty(Shape):
pass
......@@ -39,6 +39,17 @@ def test_new_del():
del rect, circ
print constructor_count-c, destructor_count-d
def test_default_constructor():
"""
>>> test_default_constructor()
0.0
"""
shape = new Empty()
try:
return shape.area()
finally:
del shape
def test_rect_area(w, h):
"""
>>> test_rect_area(3, 4)
......
......@@ -49,6 +49,7 @@ namespace shapes {
};
class Empty : public Shape {
public:
float area() { return 0; }
};
......
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