mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +00:00
Fix PR1611 - Visibility should be ignored for a declaration
when a definition's visibility is different. Likewise, the visibility of two declarations mismatching is not an error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41174 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -440,8 +440,9 @@ static bool GetLinkageResult(GlobalValue *Dest, GlobalValue *Src,
|
|||||||
|
|
||||||
// Check visibility
|
// Check visibility
|
||||||
if (Dest && Src->getVisibility() != Dest->getVisibility())
|
if (Dest && Src->getVisibility() != Dest->getVisibility())
|
||||||
return Error(Err, "Linking globals named '" + Src->getName() +
|
if (!Src->isDeclaration() && !Dest->isDeclaration())
|
||||||
"': symbols have different visibilities!");
|
return Error(Err, "Linking globals named '" + Src->getName() +
|
||||||
|
"': symbols have different visibilities!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,9 +652,13 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
|||||||
|
|
||||||
// Check visibility
|
// Check visibility
|
||||||
if (DF && !DF->hasInternalLinkage() &&
|
if (DF && !DF->hasInternalLinkage() &&
|
||||||
SF->getVisibility() != DF->getVisibility())
|
SF->getVisibility() != DF->getVisibility()) {
|
||||||
return Error(Err, "Linking functions named '" + SF->getName() +
|
// If one is a prototype, ignore its visibility. Prototypes are always
|
||||||
"': symbols have different visibilities!");
|
// overridden by the definition.
|
||||||
|
if (!SF->isDeclaration() && !DF->isDeclaration())
|
||||||
|
return Error(Err, "Linking functions named '" + SF->getName() +
|
||||||
|
"': symbols have different visibilities!");
|
||||||
|
}
|
||||||
|
|
||||||
if (DF && DF->getType() != SF->getType()) {
|
if (DF && DF->getType() != SF->getType()) {
|
||||||
if (DF->isDeclaration() && !SF->isDeclaration()) {
|
if (DF->isDeclaration() && !SF->isDeclaration()) {
|
||||||
@ -695,7 +700,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
|||||||
}
|
}
|
||||||
} else if (!DF || SF->hasInternalLinkage() || DF->hasInternalLinkage()) {
|
} else if (!DF || SF->hasInternalLinkage() || DF->hasInternalLinkage()) {
|
||||||
// Function does not already exist, simply insert an function signature
|
// Function does not already exist, simply insert an function signature
|
||||||
// identical to SF into the dest module...
|
// identical to SF into the dest module.
|
||||||
Function *NewDF = new Function(SF->getFunctionType(), SF->getLinkage(),
|
Function *NewDF = new Function(SF->getFunctionType(), SF->getLinkage(),
|
||||||
SF->getName(), Dest);
|
SF->getName(), Dest);
|
||||||
CopyGVAttributes(NewDF, SF);
|
CopyGVAttributes(NewDF, SF);
|
||||||
@ -724,6 +729,8 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
|||||||
// Link the external functions, update linkage qualifiers
|
// Link the external functions, update linkage qualifiers
|
||||||
ValueMap.insert(std::make_pair(SF, DF));
|
ValueMap.insert(std::make_pair(SF, DF));
|
||||||
DF->setLinkage(SF->getLinkage());
|
DF->setLinkage(SF->getLinkage());
|
||||||
|
// Visibility of prototype is overridden by vis of definition.
|
||||||
|
DF->setVisibility(SF->getVisibility());
|
||||||
} else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage()) {
|
} else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage()) {
|
||||||
// At this point we know that DF has LinkOnce, Weak, or External* linkage.
|
// At this point we know that DF has LinkOnce, Weak, or External* linkage.
|
||||||
ValueMap.insert(std::make_pair(SF, DF));
|
ValueMap.insert(std::make_pair(SF, DF));
|
||||||
|
Reference in New Issue
Block a user