@@ -145,6 +145,33 @@ TEST(VerifierTest, CrossModuleMetadataRef) {
145145 .startswith (" Referencing global in another module!" ));
146146}
147147
148+ TEST (VerifierTest, InvalidVariableLinkage) {
149+ LLVMContext C;
150+ Module M (" M" , C);
151+ new GlobalVariable (M, Type::getInt8Ty (C), false ,
152+ GlobalValue::LinkOnceODRLinkage, nullptr , " Some Global" );
153+ std::string Error;
154+ raw_string_ostream ErrorOS (Error);
155+ EXPECT_TRUE (verifyModule (M, &ErrorOS));
156+ EXPECT_TRUE (
157+ StringRef (ErrorOS.str ()).startswith (" Global is external, but doesn't "
158+ " have external or weak linkage!" ));
159+ }
160+
161+ TEST (VerifierTest, InvalidFunctionLinkage) {
162+ LLVMContext C;
163+ Module M (" M" , C);
164+
165+ FunctionType *FTy = FunctionType::get (Type::getVoidTy (C), /* isVarArg=*/ false );
166+ Function::Create (FTy, GlobalValue::LinkOnceODRLinkage, " foo" , &M);
167+ std::string Error;
168+ raw_string_ostream ErrorOS (Error);
169+ EXPECT_TRUE (verifyModule (M, &ErrorOS));
170+ EXPECT_TRUE (
171+ StringRef (ErrorOS.str ()).startswith (" Global is external, but doesn't "
172+ " have external or weak linkage!" ));
173+ }
174+
148175#ifndef _MSC_VER
149176// FIXME: This test causes an ICE in MSVC 2013.
150177TEST (VerifierTest, StripInvalidDebugInfo) {
0 commit comments