Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 1221:f41ff8ccc249
Unbreak nested naked functions.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Fri, 17 Apr 2009 01:14:35 +0200 |
parents | 7977096f0e49 |
children | f1877b6be63d |
comparison
equal
deleted
inserted
replaced
1220:e945d2a0999e | 1221:f41ff8ccc249 |
---|---|
313 else | 313 else |
314 { | 314 { |
315 assert(0 && "not global/function"); | 315 assert(0 && "not global/function"); |
316 } | 316 } |
317 | 317 |
318 // The following breaks for nested naked functions, so check for that. | |
319 bool skipNestedCheck = false; | |
320 if (FuncDeclaration* fd = sym->isFuncDeclaration()) | |
321 skipNestedCheck = (fd->naked != 0); | |
322 | |
318 // Any symbol nested in a function can't be referenced directly from | 323 // Any symbol nested in a function can't be referenced directly from |
319 // outside that function, so we can give such symbols internal linkage. | 324 // outside that function, so we can give such symbols internal linkage. |
320 // This holds even if nested indirectly, such as member functions of | 325 // This holds even if nested indirectly, such as member functions of |
321 // aggregates nested in functions. | 326 // aggregates nested in functions. |
322 // | 327 // |
326 // --- | 331 // --- |
327 // int counter(T)() { static int i; return i++; }" | 332 // int counter(T)() { static int i; return i++; }" |
328 // --- | 333 // --- |
329 // if instances get emitted in multiple object files because they'd use | 334 // if instances get emitted in multiple object files because they'd use |
330 // different instances of 'i'. | 335 // different instances of 'i'. |
331 for (Dsymbol* parent = sym->parent; parent ; parent = parent->parent) { | 336 if (!skipNestedCheck) |
332 if (parent->isFuncDeclaration()) | 337 for (Dsymbol* parent = sym->parent; parent ; parent = parent->parent) { |
333 return llvm::GlobalValue::InternalLinkage; | 338 if (parent->isFuncDeclaration()) |
334 } | 339 return llvm::GlobalValue::InternalLinkage; |
340 } | |
335 | 341 |
336 // default to external linkage | 342 // default to external linkage |
337 return llvm::GlobalValue::ExternalLinkage; | 343 return llvm::GlobalValue::ExternalLinkage; |
338 } | 344 } |
339 | 345 |