зеркало из https://github.com/microsoft/clang-1.git
Fix a bug where we didn't check the RHS for null, we checked
the LHS for null twice. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49138 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
988ee6ef54
Коммит
bc896f58c7
|
@ -1494,13 +1494,15 @@ inline QualType Sema::CheckCompareOperands( // C99 6.5.8
|
|||
// when handling null pointer constants. One day, we can consider making them
|
||||
// errors (when -pedantic-errors is enabled).
|
||||
if (lType->isPointerType() && rType->isPointerType()) { // C99 6.5.8p2
|
||||
QualType lpointee = lType->getAsPointerType()->getPointeeType();
|
||||
QualType rpointee = rType->getAsPointerType()->getPointeeType();
|
||||
QualType LCanPointeeTy =
|
||||
lType->getAsPointerType()->getPointeeType().getCanonicalType();
|
||||
QualType RCanPointeeTy =
|
||||
rType->getAsPointerType()->getPointeeType().getCanonicalType();
|
||||
|
||||
if (!LHSIsNull && !RHSIsNull && // C99 6.5.9p2
|
||||
!lpointee->isVoidType() && !lpointee->isVoidType() &&
|
||||
!Context.typesAreCompatible(lpointee.getUnqualifiedType(),
|
||||
rpointee.getUnqualifiedType())) {
|
||||
!LCanPointeeTy->isVoidType() && !RCanPointeeTy->isVoidType() &&
|
||||
!Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
|
||||
RCanPointeeTy.getUnqualifiedType())) {
|
||||
Diag(loc, diag::ext_typecheck_comparison_of_distinct_pointers,
|
||||
lType.getAsString(), rType.getAsString(),
|
||||
lex->getSourceRange(), rex->getSourceRange());
|
||||
|
|
Загрузка…
Ссылка в новой задаче