diff options
author | Chris Lattner <sabre@nondot.org> | 2004-08-20 00:30:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-08-20 00:30:39 +0000 |
commit | 4e4c444d5c9d83992dafa7f3e40901567f90b754 (patch) | |
tree | e3da1a7289ae69e4223622b98ce51d1bfab91f68 /lib/Transforms/IPO/FunctionResolution.cpp | |
parent | 43f20a56b28c52339d2a007e88043fa42744641b (diff) |
If we are linking two global variables and they have the same size, do not
spew warnings, even if the types don't match.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15933 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/FunctionResolution.cpp')
-rw-r--r-- | lib/Transforms/IPO/FunctionResolution.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp index 9cf26b6192..8403226ba3 100644 --- a/lib/Transforms/IPO/FunctionResolution.cpp +++ b/lib/Transforms/IPO/FunctionResolution.cpp @@ -236,14 +236,15 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD, // size of 0, and the concrete global is an array with a real size, don't // warn. This occurs due to declaring 'extern int A[];'. if (GlobalVariable *ConcreteGV = dyn_cast<GlobalVariable>(Concrete)) - if (GlobalVariable *OtherGV = dyn_cast<GlobalVariable>(Other)) - if (const ArrayType *OtherAT = - dyn_cast<ArrayType>(OtherGV->getType()->getElementType())) - if (const ArrayType *ConcreteAT = - dyn_cast<ArrayType>(ConcreteGV->getType()->getElementType())) - if (OtherAT->getElementType() == ConcreteAT->getElementType() && - OtherAT->getNumElements() == 0) - DontPrintWarning = true; + if (GlobalVariable *OtherGV = dyn_cast<GlobalVariable>(Other)) { + const Type *CTy = ConcreteGV->getType(); + const Type *OTy = OtherGV->getType(); + + if (CTy->isSized()) + if (!OTy->isSized() || !TD.getTypeSize(OTy) || + TD.getTypeSize(OTy) == TD.getTypeSize(CTy)) + DontPrintWarning = true; + } } if (!DontPrintWarning) { |