aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-08-22 01:48:21 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-08-22 01:48:21 +0000
commit3bc0f45a5e65814f42b22dcdf7249d1120d16f36 (patch)
treec44ed401376dff0f9239b163e0b95a5589032cd8
parent86da77fdaf4c0237eafb9670f54eee20b08635bf (diff)
Fix some issues with array type merging. (No visible difference,
because nothing uses the merged types yet.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55161 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ASTContext.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index b8b15628d7..bb8743babd 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1849,8 +1849,8 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
QualType RHSPointee = RHS->getAsPointerType()->getPointeeType();
QualType ResultType = mergeTypes(LHSPointee, RHSPointee);
if (ResultType.isNull()) return QualType();
- if (getCanonicalType(LHSPointee) != getCanonicalType(ResultType)) return LHS;
- if (getCanonicalType(RHSPointee) != getCanonicalType(ResultType)) return RHS;
+ if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType)) return LHS;
+ if (getCanonicalType(RHSPointee) == getCanonicalType(ResultType)) return RHS;
return getPointerType(ResultType);
}
case Type::ConstantArray:
@@ -1864,12 +1864,16 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
QualType RHSElem = getAsArrayType(RHS)->getElementType();
QualType ResultType = mergeTypes(LHSElem, RHSElem);
if (ResultType.isNull()) return QualType();
- if (LCAT && getCanonicalType(LHSElem) != getCanonicalType(ResultType)) return LHS;
- if (RCAT && getCanonicalType(RHSElem) != getCanonicalType(ResultType)) return RHS;
+ if (LCAT && getCanonicalType(LHSElem) == getCanonicalType(ResultType)) return LHS;
+ if (RCAT && getCanonicalType(RHSElem) == getCanonicalType(ResultType)) return RHS;
+ if (LCAT) return getConstantArrayType(ResultType, LCAT->getSize(),
+ ArrayType::ArraySizeModifier(), 0);
+ if (RCAT) return getConstantArrayType(ResultType, RCAT->getSize(),
+ ArrayType::ArraySizeModifier(), 0);
const VariableArrayType* LVAT = getAsVariableArrayType(LHS);
const VariableArrayType* RVAT = getAsVariableArrayType(RHS);
- if (LVAT && getCanonicalType(LHSElem) != getCanonicalType(ResultType)) return LHS;
- if (RVAT && getCanonicalType(RHSElem) != getCanonicalType(ResultType)) return RHS;
+ if (LVAT && getCanonicalType(LHSElem) == getCanonicalType(ResultType)) return LHS;
+ if (RVAT && getCanonicalType(RHSElem) == getCanonicalType(ResultType)) return RHS;
if (LVAT) {
// FIXME: This isn't correct! But tricky to implement because
// the array's size has to be the size of LHS, but the type
@@ -1882,8 +1886,8 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
// has to be different.
return RHS;
}
- if (getCanonicalType(LHSElem) != getCanonicalType(ResultType)) return LHS;
- if (getCanonicalType(RHSElem) != getCanonicalType(ResultType)) return RHS;
+ if (getCanonicalType(LHSElem) == getCanonicalType(ResultType)) return LHS;
+ if (getCanonicalType(RHSElem) == getCanonicalType(ResultType)) return RHS;
return getIncompleteArrayType(ResultType, ArrayType::ArraySizeModifier(), 0);
}
case Type::FunctionNoProto: