llvm-as: t.ll:2:39: function may not return opaque type
%"bwmoyl" = tail call coldcc opaque @g()
^
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61933
91177308-0d34-0410-b5e6-
96231b3b80d8
// Otherwise, create a new forward reference for this value and remember it.
GlobalValue *FwdVal;
// Otherwise, create a new forward reference for this value and remember it.
GlobalValue *FwdVal;
- if (const FunctionType *FT = dyn_cast<FunctionType>(PTy->getElementType()))
+ if (const FunctionType *FT = dyn_cast<FunctionType>(PTy->getElementType())) {
+ // Function types can return opaque but functions can't.
+ if (isa<OpaqueType>(FT->getReturnType())) {
+ Error(Loc, "function may not return opaque type");
+ return 0;
+ }
+
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
FwdVal = new GlobalVariable(PTy->getElementType(), false,
GlobalValue::ExternalWeakLinkage, 0, Name, M);
FwdVal = new GlobalVariable(PTy->getElementType(), false,
GlobalValue::ExternalWeakLinkage, 0, Name, M);
ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
return FwdVal;
ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
return FwdVal;