aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-05 05:21:07 +0000
committerChris Lattner <sabre@nondot.org>2009-08-05 05:21:07 +0000
commit26d054d903488d956c23a17d78b6bc8cbd9553cb (patch)
tree6b4c81395f4dab5e0e31865699f082c693c68d6e /lib/VMCore
parent831f6f6d2ae5a1ad988c8328404b052b7985ce31 (diff)
downloadexternal_llvm-26d054d903488d956c23a17d78b6bc8cbd9553cb.zip
external_llvm-26d054d903488d956c23a17d78b6bc8cbd9553cb.tar.gz
external_llvm-26d054d903488d956c23a17d78b6bc8cbd9553cb.tar.bz2
Clarify common linkage and the requirements on it. Enforce
them in the verifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Verifier.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 2b83298..f50299b 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -378,6 +378,12 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) {
"Global variable initializer type does not match global "
"variable type!", &GV);
+ // If the global has common linkage, it must have a zero initializer.
+ if (GV.hasCommonLinkage())
+ Assert1(GV.getInitializer()->isNullValue(),
+ "'common' global must have a zero initializer!", &GV);
+
+
// Verify that any metadata used in a global initializer points only to
// other globals.
if (MDNode *FirstNode = dyn_cast<MDNode>(GV.getInitializer())) {
@@ -544,6 +550,7 @@ void Verifier::visitFunction(Function &F) {
const FunctionType *FT = F.getFunctionType();
unsigned NumArgs = F.arg_size();
+ Assert1(!F.hasCommonLinkage(), "Functions may not have common linkage", &F);
Assert2(FT->getNumParams() == NumArgs,
"# formal arguments must match # of arguments for function type!",
&F, FT);