+
+#ifdef GTEST_HAS_DEATH_TEST
+#ifndef NDEBUG
+TEST(GlobalTest, AlignDeath) {
+ LLVMContext &Ctx = getGlobalContext();
+ std::unique_ptr<Module> M(new Module("TestModule", Ctx));
+ Type *Int32Ty = Type::getInt32Ty(Ctx);
+ GlobalVariable *Var =
+ new GlobalVariable(*M, Int32Ty, true, GlobalValue::ExternalLinkage,
+ Constant::getAllOnesValue(Int32Ty), "var", nullptr,
+ GlobalVariable::NotThreadLocal, 1);
+
+ EXPECT_DEATH(Var->setAlignment(536870913U), "Alignment is not a power of 2");
+ EXPECT_DEATH(Var->setAlignment(1073741824U),
+ "Alignment is greater than MaximumAlignment");
+}
+#endif
+#endif
+