forked from OSchip/llvm-project
Fix the address of a label to be properly considered and emitted as a
constant. llvm-svn: 62948
This commit is contained in:
parent
8b7c52658b
commit
529a99bcf4
|
@ -215,6 +215,8 @@ public:
|
|||
APValue VisitUnaryOperator(const UnaryOperator *E);
|
||||
APValue VisitObjCStringLiteral(ObjCStringLiteral *E)
|
||||
{ return APValue(E, 0); }
|
||||
APValue VisitAddrLabelExpr(AddrLabelExpr *E)
|
||||
{ return APValue(E, 0); }
|
||||
APValue VisitConditionalOperator(ConditionalOperator *E);
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
|
|
@ -619,6 +619,12 @@ public:
|
|||
|
||||
return CGM.GetAddrOfConstantCString(Str, ".tmp");
|
||||
}
|
||||
case Expr::AddrLabelExprClass: {
|
||||
assert(CGF && "Invalid address of label expression outside function.");
|
||||
unsigned id = CGF->GetIDForAddrOfLabel(cast<AddrLabelExpr>(E)->getLabel());
|
||||
llvm::Constant *C = llvm::ConstantInt::get(llvm::Type::Int32Ty, id);
|
||||
return llvm::ConstantExpr::getIntToPtr(C, ConvertType(E->getType()));
|
||||
}
|
||||
}
|
||||
CGM.ErrorUnsupported(E, "constant l-value expression");
|
||||
llvm::Type *Ty = llvm::PointerType::getUnqual(ConvertType(E->getType()));
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
// RUN: clang %s -emit-llvm -o %t
|
||||
int a() {
|
||||
A:;static void* a = &&A;
|
||||
}
|
Loading…
Reference in New Issue