Index: lib/Sema/SemaChecking.cpp =================================================================== --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -7075,6 +7075,12 @@ return IntRange(C.getIntWidth(QualType(T, 0)), BT->isUnsignedInteger()); } + /// Returns the "target" range of a given integral type. + static IntRange forTargetOfType(ASTContext &C, QualType T) { + return forTargetOfCanonicalType(C, + T->getCanonicalTypeInternal().getTypePtr()); + } + /// Returns the "target" range of a canonical integral type, i.e. /// the range of values expressible in the type. /// @@ -7492,7 +7498,9 @@ QualType OtherT = Other->getType(); if (const auto *AT = OtherT->getAs()) OtherT = AT->getValueType(); - IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT); + IntRange OtherRange = S.getLangOpts().CPlusPlus + ? IntRange::forValueOfType(S.Context, OtherT) + : IntRange::forTargetOfType(S.Context, OtherT); unsigned OtherWidth = OtherRange.Width; bool OtherIsBooleanType = Other->isKnownToHaveBooleanValue();