Linker: Fix #1329: correctly merge unsized arrays, and fix link tests.
This commit is contained in:
parent
ed834895ea
commit
5a867acad5
6 changed files with 355 additions and 47 deletions
|
|
@ -268,12 +268,13 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin
|
|||
// Recursively merge the implicit array sizes through the objects' respective type trees.
|
||||
void TIntermediate::mergeImplicitArraySizes(TType& type, const TType& unitType)
|
||||
{
|
||||
if (type.isUnsizedArray() && unitType.isArray()) {
|
||||
int newImplicitArraySize = unitType.isSizedArray() ? unitType.getOuterArraySize() :
|
||||
unitType.getImplicitArraySize();
|
||||
type.updateImplicitArraySize(type.getImplicitArraySize());
|
||||
if (unitType.isArrayVariablyIndexed())
|
||||
type.setArrayVariablyIndexed();
|
||||
if (type.isUnsizedArray()) {
|
||||
if (unitType.isUnsizedArray()) {
|
||||
type.updateImplicitArraySize(unitType.getImplicitArraySize());
|
||||
if (unitType.isArrayVariablyIndexed())
|
||||
type.setArrayVariablyIndexed();
|
||||
} else if (unitType.isSizedArray())
|
||||
type.changeOuterArraySize(unitType.getOuterArraySize());
|
||||
}
|
||||
|
||||
// Type mismatches are caught and reported after this, just be careful for now.
|
||||
|
|
@ -296,8 +297,13 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
|
|||
|
||||
// Types have to match
|
||||
if (symbol.getType() != unitSymbol.getType()) {
|
||||
error(infoSink, "Types must match:");
|
||||
writeTypeComparison = true;
|
||||
// but, we make an exception if one is an implicit array and the other is sized
|
||||
if (! (symbol.getType().isArray() && unitSymbol.getType().isArray() &&
|
||||
symbol.getType().sameElementType(unitSymbol.getType()) &&
|
||||
(symbol.getType().isUnsizedArray() || unitSymbol.getType().isUnsizedArray()))) {
|
||||
error(infoSink, "Types must match:");
|
||||
writeTypeComparison = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Qualifiers have to (almost) match
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue