Add unit test to test a trivial verifier check.
authorBill Wendling <isanbard@gmail.com>
Wed, 19 Jun 2013 19:26:44 +0000 (19:26 +0000)
committerBill Wendling <isanbard@gmail.com>
Wed, 19 Jun 2013 19:26:44 +0000 (19:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184338 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/IR/VerifierTest.cpp

index 89119368fbd923ef1cfc2e0711e61663ed2c6161..2848cb82cf05ee58c7bf066fa5c6dfad116e9141 100644 (file)
@@ -60,5 +60,21 @@ TEST(VerifierTest, AliasUnnamedAddr) {
   EXPECT_TRUE(verifyModule(M, ReturnStatusAction, &Error));
   EXPECT_TRUE(StringRef(Error).startswith("Alias cannot have unnamed_addr"));
 }
+
+TEST(VerifierTest, InvalidRetAttribute) {
+  LLVMContext &C = getGlobalContext();
+  Module M("M", C);
+  FunctionType *FTy = FunctionType::get(Type::getInt32Ty(C), /*isVarArg=*/false);
+  Function *F = cast<Function>(M.getOrInsertFunction("foo", FTy));
+  AttributeSet AS = F->getAttributes();
+  F->setAttributes(AS.addAttribute(C, AttributeSet::ReturnIndex,
+                                   Attribute::UWTable));
+
+  std::string Error;
+  EXPECT_TRUE(verifyModule(M, ReturnStatusAction, &Error));
+  EXPECT_TRUE(StringRef(Error).
+              startswith("Attribute 'uwtable' only applies to functions!"));
+}
+
 }
 }