reject PR3281:crash11.ll with:
authorChris Lattner <sabre@nondot.org>
Mon, 5 Jan 2009 18:27:50 +0000 (18:27 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 5 Jan 2009 18:27:50 +0000 (18:27 +0000)
llvm-as: crash11.ll:2:27: function may not return return opaque type
  "xw" = tail call opaque @608(label %31)
                          ^

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61722 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLParser.cpp

index c13737aae5259d0369efbb476c3f70596369a823..a9f8e192d382842351d88035a4415f9e336ce26f 100644 (file)
@@ -602,11 +602,17 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc) {
   
   // 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 return opaque type");
+      return 0;
+    }
     FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M);
-  else
+  } else {
     FwdVal = new GlobalVariable(PTy->getElementType(), false,
                                 GlobalValue::ExternalWeakLinkage, 0, "", M);
+  }
   
   ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc);
   return FwdVal;