mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	ast/dpicall: Stop using variable length array
Fix the compiler warning
    variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
			
			
This commit is contained in:
		
							parent
							
								
									98f0ddd636
								
							
						
					
					
						commit
						732ed67014
					
				
					 1 changed files with 6 additions and 5 deletions
				
			
		|  | @ -67,9 +67,10 @@ static ffi_fptr resolve_fn (std::string symbol_name) | ||||||
| AST::AstNode *AST::dpi_call(const std::string &rtype, const std::string &fname, const std::vector<std::string> &argtypes, const std::vector<AstNode*> &args) | AST::AstNode *AST::dpi_call(const std::string &rtype, const std::string &fname, const std::vector<std::string> &argtypes, const std::vector<AstNode*> &args) | ||||||
| { | { | ||||||
| 	AST::AstNode *newNode = nullptr; | 	AST::AstNode *newNode = nullptr; | ||||||
| 	union { double f64; float f32; int32_t i32; void *ptr; } value_store [args.size() + 1]; | 	union value { double f64; float f32; int32_t i32; void *ptr; }; | ||||||
| 	ffi_type *types [args.size() + 1]; | 	std::vector<value> value_store(args.size() + 1); | ||||||
| 	void *values [args.size() + 1]; | 	std::vector<ffi_type *> types(args.size() + 1); | ||||||
|  | 	std::vector<void *> values(args.size() + 1); | ||||||
| 	ffi_cif cif; | 	ffi_cif cif; | ||||||
| 	int status; | 	int status; | ||||||
| 
 | 
 | ||||||
|  | @ -118,10 +119,10 @@ AST::AstNode *AST::dpi_call(const std::string &rtype, const std::string &fname, | ||||||
|                 log_error("invalid rtype '%s'.\n", rtype.c_str()); |                 log_error("invalid rtype '%s'.\n", rtype.c_str()); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, args.size(), types[args.size()], types)) != FFI_OK) |         if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, args.size(), types[args.size()], types.data())) != FFI_OK) | ||||||
|                 log_error("ffi_prep_cif failed: status %d.\n", status); |                 log_error("ffi_prep_cif failed: status %d.\n", status); | ||||||
| 
 | 
 | ||||||
|         ffi_call(&cif, resolve_fn(fname.c_str()), values[args.size()], values); |         ffi_call(&cif, resolve_fn(fname.c_str()), values[args.size()], values.data()); | ||||||
| 
 | 
 | ||||||
| 	if (rtype == "real") { | 	if (rtype == "real") { | ||||||
| 		newNode = new AstNode(AST_REALVALUE); | 		newNode = new AstNode(AST_REALVALUE); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue