Emit all D inline asm labels as local labels.

On OS X, there is an actual significance to the distinction, which before lead e.g. to exception throwing in the below example being broken:

---
import core.exception;

void main() {
  asm {
    jmp Lfoo;
Lfoo:
    ;
  }
  throw cast(OutOfMemoryError)cast(void*)OutOfMemoryError.classinfo.init;
  assert(0);
}
---
This commit is contained in:
David Nadlinger
2011-12-04 18:13:33 +01:00
parent 1afc01df72
commit d0ea856024
7 changed files with 25 additions and 9 deletions

View File

@@ -1388,10 +1388,10 @@ void LabelStatement::toIR(IRState* p)
if (p->asmBlock)
{
IRAsmStmt* a = new IRAsmStmt;
a->code += p->func()->decl->mangle();
a->code += "_";
a->code += ident->toChars();
a->code += ":";
std::stringstream label;
printLabelName(label, p->func()->decl->mangle(), ident->toChars());
label << ":";
a->code = label.str();
p->asmBlock->s.push_back(a);
p->asmBlock->internalLabels.push_back(ident);