Mercurial > projects > ldc
comparison gen/tocall.cpp @ 1330:459b6b6f9a8d
Fixed D-style vararg arguments with types that have sizes bigger that pointers, yet are not aligned to pointer sizes. Fixes ticket #276 .
author | Tomas Lindquist Olsen <tomas.l.olsen gmail com> |
---|---|
date | Sun, 10 May 2009 04:37:03 +0200 |
parents | 00a84912c689 |
children | 15e9762bb620 |
comparison
equal
deleted
inserted
replaced
1329:e5b57fd8307c | 1330:459b6b6f9a8d |
---|---|
139 { | 139 { |
140 Expression* argexp = (Expression*)arguments->data[i]; | 140 Expression* argexp = (Expression*)arguments->data[i]; |
141 assert(argexp->type->ty != Ttuple); | 141 assert(argexp->type->ty != Ttuple); |
142 vtypes.push_back(DtoType(argexp->type)); | 142 vtypes.push_back(DtoType(argexp->type)); |
143 size_t sz = getTypePaddedSize(vtypes.back()); | 143 size_t sz = getTypePaddedSize(vtypes.back()); |
144 if (sz < PTRSIZE) | 144 size_t asz = (sz + PTRSIZE - 1) & ~(PTRSIZE -1); |
145 vtypes.back() = DtoSize_t(); | 145 if (sz != asz) |
146 { | |
147 if (sz < PTRSIZE) | |
148 { | |
149 vtypes.back() = DtoSize_t(); | |
150 } | |
151 else | |
152 { | |
153 // ok then... so we build some type that is big enough | |
154 // and aligned to PTRSIZE | |
155 std::vector<const LLType*> gah; | |
156 gah.reserve(asz/PTRSIZE); | |
157 size_t gah_sz = 0; | |
158 while (gah_sz < asz) | |
159 { | |
160 gah.push_back(DtoSize_t()); | |
161 gah_sz += PTRSIZE; | |
162 } | |
163 vtypes.back() = LLStructType::get(gah, true); | |
164 } | |
165 } | |
146 } | 166 } |
147 const LLStructType* vtype = LLStructType::get(vtypes); | 167 const LLStructType* vtype = LLStructType::get(vtypes); |
148 | 168 |
149 if (Logger::enabled()) | 169 if (Logger::enabled()) |
150 Logger::cout() << "d-variadic argument struct type:\n" << *vtype << '\n'; | 170 Logger::cout() << "d-variadic argument struct type:\n" << *vtype << '\n'; |