Skip to content

Commit f528402

Browse files
authored
Merge pull request #4914 from povik/rm-var-length-array
ast/dpicall: Stop using variable length array
2 parents 55595b6 + 732ed67 commit f528402

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

frontends/ast/dpicall.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ static ffi_fptr resolve_fn (std::string symbol_name)
6767
AST::AstNode *AST::dpi_call(const std::string &rtype, const std::string &fname, const std::vector<std::string> &argtypes, const std::vector<AstNode*> &args)
6868
{
6969
AST::AstNode *newNode = nullptr;
70-
union { double f64; float f32; int32_t i32; void *ptr; } value_store [args.size() + 1];
71-
ffi_type *types [args.size() + 1];
72-
void *values [args.size() + 1];
70+
union value { double f64; float f32; int32_t i32; void *ptr; };
71+
std::vector<value> value_store(args.size() + 1);
72+
std::vector<ffi_type *> types(args.size() + 1);
73+
std::vector<void *> values(args.size() + 1);
7374
ffi_cif cif;
7475
int status;
7576

@@ -118,10 +119,10 @@ AST::AstNode *AST::dpi_call(const std::string &rtype, const std::string &fname,
118119
log_error("invalid rtype '%s'.\n", rtype.c_str());
119120
}
120121

121-
if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, args.size(), types[args.size()], types)) != FFI_OK)
122+
if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, args.size(), types[args.size()], types.data())) != FFI_OK)
122123
log_error("ffi_prep_cif failed: status %d.\n", status);
123124

124-
ffi_call(&cif, resolve_fn(fname.c_str()), values[args.size()], values);
125+
ffi_call(&cif, resolve_fn(fname.c_str()), values[args.size()], values.data());
125126

126127
if (rtype == "real") {
127128
newNode = new AstNode(AST_REALVALUE);

0 commit comments

Comments
 (0)