Commit f1ce1111 authored by Xavier Thompson's avatar Xavier Thompson

Cast NULL optional arg to optional struct type only in C++

parent 56f5bad1
...@@ -5661,6 +5661,14 @@ class SimpleCallNode(CallNode): ...@@ -5661,6 +5661,14 @@ class SimpleCallNode(CallNode):
# wrapper_call bool used internally # wrapper_call bool used internally
# has_optional_args bool used internally # has_optional_args bool used internally
# nogil bool used internally # nogil bool used internally
#
# analysed bool used internally
# overflowcheck bool used internally
# explicit_cpp_self bool used internally
# rlocked bool used internally
# wlocked bool used internally
# tracked_state bool used internally
# is_in_cpp bool used internally
subexprs = ['self', 'coerced_self', 'function', 'args', 'arg_tuple'] subexprs = ['self', 'coerced_self', 'function', 'args', 'arg_tuple']
...@@ -5676,6 +5684,7 @@ class SimpleCallNode(CallNode): ...@@ -5676,6 +5684,7 @@ class SimpleCallNode(CallNode):
rlocked = False rlocked = False
wlocked = False wlocked = False
tracked_state = True # Something random, anything that is not None tracked_state = True # Something random, anything that is not None
is_in_cpp = False
def compile_time_value(self, denv): def compile_time_value(self, denv):
function = self.function.compile_time_value(denv) function = self.function.compile_time_value(denv)
...@@ -5706,6 +5715,7 @@ class SimpleCallNode(CallNode): ...@@ -5706,6 +5715,7 @@ class SimpleCallNode(CallNode):
return self.args, None return self.args, None
def analyse_types(self, env): def analyse_types(self, env):
self.is_in_cpp = env.is_cpp()
if self.analyse_as_type_constructor(env): if self.analyse_as_type_constructor(env):
return self return self
if self.analysed: if self.analysed:
...@@ -6066,12 +6076,11 @@ class SimpleCallNode(CallNode): ...@@ -6066,12 +6076,11 @@ class SimpleCallNode(CallNode):
if func_type.optional_arg_count: if func_type.optional_arg_count:
if expected_nargs == actual_nargs: if expected_nargs == actual_nargs:
# Cast NULL to optional struct type to avoid ambiguous calls # Cast NULL to optional struct type to avoid ambiguous calls in C++
opt_struct_type = func_type.op_arg_struct.base_type if self.is_in_cpp:
if opt_struct_type.typedef_flag: optional_args = '(%s *)NULL' % func_type.op_arg_struct.base_type.cname
optional_args = '(%s *)NULL' % opt_struct_type.cname
else: else:
optional_args = '(%s %s *)NULL' % (opt_struct_type.kind, opt_struct_type.cname) optional_args = 'NULL'
else: else:
optional_args = "&%s" % self.opt_arg_struct optional_args = "&%s" % self.opt_arg_struct
arg_list_code.append(optional_args) arg_list_code.append(optional_args)
......
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