comparison gen/tocall.cpp @ 1178:a668f4051368

Fix a bug I noticed. Varargs were broken if preceded by tuple parameters.
author Frits van Bommel <fvbommel wxs.nl>
date Mon, 30 Mar 2009 00:00:43 +0200
parents 5ebe8224988b
children 83d3b25c2213
comparison
equal deleted inserted replaced
1177:a8b9fc41c34b 1178:a668f4051368
120 ////////////////////////////////////////////////////////////////////////////////////////// 120 //////////////////////////////////////////////////////////////////////////////////////////
121 121
122 void DtoBuildDVarArgList(std::vector<LLValue*>& args, std::vector<llvm::AttributeWithIndex>& attrs, TypeFunction* tf, Expressions* arguments, size_t argidx) 122 void DtoBuildDVarArgList(std::vector<LLValue*>& args, std::vector<llvm::AttributeWithIndex>& attrs, TypeFunction* tf, Expressions* arguments, size_t argidx)
123 { 123 {
124 Logger::println("doing d-style variadic arguments"); 124 Logger::println("doing d-style variadic arguments");
125 LOG_SCOPE
125 126
126 std::vector<const LLType*> vtypes; 127 std::vector<const LLType*> vtypes;
127 128
128 // number of non variadic args 129 // number of non variadic args
129 int begin = tf->parameters->dim; 130 int begin = Argument::dim(tf->parameters);
130 Logger::println("num non vararg params = %d", begin); 131 Logger::println("num non vararg params = %d", begin);
131 132
132 // get n args in arguments list 133 // get n args in arguments list
133 size_t n_arguments = arguments ? arguments->dim : 0; 134 size_t n_arguments = arguments ? arguments->dim : 0;
134 135
135 // build struct with argument types (non variadic args) 136 // build struct with argument types (non variadic args)
136 for (int i=begin; i<n_arguments; i++) 137 for (int i=begin; i<n_arguments; i++)
137 { 138 {
138 Expression* argexp = (Expression*)arguments->data[i]; 139 Expression* argexp = (Expression*)arguments->data[i];
140 assert(argexp->type->ty != Ttuple);
139 vtypes.push_back(DtoType(argexp->type)); 141 vtypes.push_back(DtoType(argexp->type));
140 size_t sz = getTypePaddedSize(vtypes.back()); 142 size_t sz = getTypePaddedSize(vtypes.back());
141 if (sz < PTRSIZE) 143 if (sz < PTRSIZE)
142 vtypes.back() = DtoSize_t(); 144 vtypes.back() = DtoSize_t();
143 } 145 }