From: Robert Bradshaw Date: Thu, 4 Feb 2010 22:44:21 +0000 (-0800) Subject: More restrictions on stack allocated C++ objects. X-Git-Tag: 0.13.beta0~353^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=09cbfe821a3c4b7dd2045af14b4306fd232d14c9;p=cython.git More restrictions on stack allocated C++ objects. --- diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 162acb9f..d9f5995c 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -431,6 +431,10 @@ class Scope(object): cname = name else: cname = self.mangle(Naming.var_prefix, name) + if type.is_cpp_class and visibility != 'extern': + constructor = type.scope.lookup(u'') + if constructor is not None and PyrexTypes.best_match([], constructor.all_alternatives()) is None: + error(pos, "C++ class must have an empty constructor to be stack allocated") entry = self.declare(name, cname, type, pos, visibility) entry.is_variable = 1 self.control_flow.set_state((), (name, 'initalized'), False) @@ -1359,6 +1363,8 @@ class CClassScope(ClassScope): cname = name if visibility == 'private': cname = c_safe_identifier(cname) + if type.is_cpp_class and visibility != 'extern': + error(pos, "C++ classes not allowed as members of an extension type, use a pointer or reference instead") entry = self.declare(name, cname, type, pos, visibility) entry.is_variable = 1 self.var_entries.append(entry)