@@ -1849,8 +1849,8 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
1849
1849
QualType RHSPointee = RHS->getAsPointerType ()->getPointeeType ();
1850
1850
QualType ResultType = mergeTypes (LHSPointee, RHSPointee);
1851
1851
if (ResultType.isNull ()) return QualType ();
1852
- if (getCanonicalType (LHSPointee) ! = getCanonicalType (ResultType)) return LHS;
1853
- if (getCanonicalType (RHSPointee) ! = getCanonicalType (ResultType)) return RHS;
1852
+ if (getCanonicalType (LHSPointee) = = getCanonicalType (ResultType)) return LHS;
1853
+ if (getCanonicalType (RHSPointee) = = getCanonicalType (ResultType)) return RHS;
1854
1854
return getPointerType (ResultType);
1855
1855
}
1856
1856
case Type::ConstantArray:
@@ -1864,12 +1864,16 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
1864
1864
QualType RHSElem = getAsArrayType (RHS)->getElementType ();
1865
1865
QualType ResultType = mergeTypes (LHSElem, RHSElem);
1866
1866
if (ResultType.isNull ()) return QualType ();
1867
- if (LCAT && getCanonicalType (LHSElem) != getCanonicalType (ResultType)) return LHS;
1868
- if (RCAT && getCanonicalType (RHSElem) != getCanonicalType (ResultType)) return RHS;
1867
+ if (LCAT && getCanonicalType (LHSElem) == getCanonicalType (ResultType)) return LHS;
1868
+ if (RCAT && getCanonicalType (RHSElem) == getCanonicalType (ResultType)) return RHS;
1869
+ if (LCAT) return getConstantArrayType (ResultType, LCAT->getSize (),
1870
+ ArrayType::ArraySizeModifier (), 0 );
1871
+ if (RCAT) return getConstantArrayType (ResultType, RCAT->getSize (),
1872
+ ArrayType::ArraySizeModifier (), 0 );
1869
1873
const VariableArrayType* LVAT = getAsVariableArrayType (LHS);
1870
1874
const VariableArrayType* RVAT = getAsVariableArrayType (RHS);
1871
- if (LVAT && getCanonicalType (LHSElem) ! = getCanonicalType (ResultType)) return LHS;
1872
- if (RVAT && getCanonicalType (RHSElem) ! = getCanonicalType (ResultType)) return RHS;
1875
+ if (LVAT && getCanonicalType (LHSElem) = = getCanonicalType (ResultType)) return LHS;
1876
+ if (RVAT && getCanonicalType (RHSElem) = = getCanonicalType (ResultType)) return RHS;
1873
1877
if (LVAT) {
1874
1878
// FIXME: This isn't correct! But tricky to implement because
1875
1879
// 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) {
1882
1886
// has to be different.
1883
1887
return RHS;
1884
1888
}
1885
- if (getCanonicalType (LHSElem) ! = getCanonicalType (ResultType)) return LHS;
1886
- if (getCanonicalType (RHSElem) ! = getCanonicalType (ResultType)) return RHS;
1889
+ if (getCanonicalType (LHSElem) = = getCanonicalType (ResultType)) return LHS;
1890
+ if (getCanonicalType (RHSElem) = = getCanonicalType (ResultType)) return RHS;
1887
1891
return getIncompleteArrayType (ResultType, ArrayType::ArraySizeModifier (), 0 );
1888
1892
}
1889
1893
case Type::FunctionNoProto:
0 commit comments