Commit 69d0430d authored by Xavier Thompson's avatar Xavier Thompson

Fix and type-check casts to qualified cypclass

parent f7b2cfd1
...@@ -10951,6 +10951,9 @@ class TypecastNode(ExprNode): ...@@ -10951,6 +10951,9 @@ class TypecastNode(ExprNode):
self.op_func_type = entry.type self.op_func_type = entry.type
if self.type.is_cyp_class: if self.type.is_cyp_class:
self.is_temp = self.overloaded self.is_temp = self.overloaded
if self.type.is_qualified_cyp_class:
if not self.type.assignable_from(self.operand.type):
error(self.pos, "Cannot cast %s to %s" % (self.operand.type, self.type))
if self.type.is_ptr and self.type.base_type.is_cfunction and self.type.base_type.nogil: if self.type.is_ptr and self.type.base_type.is_cfunction and self.type.base_type.nogil:
op_type = self.operand.type op_type = self.operand.type
if op_type.is_ptr: if op_type.is_ptr:
......
...@@ -321,7 +321,8 @@ def p_typecast(s): ...@@ -321,7 +321,8 @@ def p_typecast(s):
is_memslice = isinstance(base_type, Nodes.MemoryViewSliceTypeNode) is_memslice = isinstance(base_type, Nodes.MemoryViewSliceTypeNode)
is_template = isinstance(base_type, Nodes.TemplatedTypeNode) is_template = isinstance(base_type, Nodes.TemplatedTypeNode)
is_const_volatile = isinstance(base_type, Nodes.CConstOrVolatileTypeNode) is_const_volatile = isinstance(base_type, Nodes.CConstOrVolatileTypeNode)
if not is_memslice and not is_template and not is_const_volatile and base_type.name is None: is_qualified = isinstance(base_type, Nodes.QualifiedCypclassNode)
if not is_memslice and not is_template and not is_const_volatile and not is_qualified and base_type.name is None:
s.error("Unknown type") s.error("Unknown type")
declarator = p_c_declarator(s, empty = 1) declarator = p_c_declarator(s, empty = 1)
if s.sy == '?': if s.sy == '?':
......
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