Tighten up ASTContext::typesAreCompatible()...it needs to make sure the qualifiers match. The comment and C99 citation for this routine were correct...the code needed to conform to the comment/spec. This fixes the test added below.
Tightening up this routine forced tweaks to Sema::CheckSubtractionOperands() and Sema::CheckCompareOperands(). For example, they both need to operate on the unqualified pointee...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46522 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index c86cf67..8d620d9 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -1617,6 +1617,9 @@
/// C99 6.2.7p1: Two types have compatible types if their types are the
/// same. See 6.7.[2,3,5] for additional rules.
bool ASTContext::typesAreCompatible(QualType lhs, QualType rhs) {
+ if (lhs.getQualifiers() != rhs.getQualifiers())
+ return false;
+
QualType lcanon = lhs.getCanonicalType();
QualType rcanon = rhs.getCanonicalType();