aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-07 05:43:21 +0000
committerChris Lattner <sabre@nondot.org>2008-04-07 05:43:21 +0000
commita36a61f218b9f7a97f2c0f511e0b29eb42e8f78b (patch)
tree11ad248b5ac60d231ef8a7d60e911930639ad9c2 /lib/AST/ASTContext.cpp
parentf3692dc4a47dc48d10cec0415c6e9e39b7a39707 (diff)
ocuvector and vector should be compatible. Fix ASQual compatibility.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49316 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index bd914fd984..5a7315256c 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1642,9 +1642,15 @@ bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) {
return true;
// If qualifiers differ, the types are different.
- if (LHS.getCVRQualifiers() != RHS.getCVRQualifiers() ||
- LHS.getAddressSpace() != RHS.getAddressSpace())
+ unsigned LHSAS = LHS.getAddressSpace(), RHSAS = RHS.getAddressSpace();
+ if (LHS.getCVRQualifiers() != RHS.getCVRQualifiers() || LHSAS != RHSAS)
return false;
+
+ // Strip off ASQual's if present.
+ if (LHSAS) {
+ LHS = LHS.getUnqualifiedType();
+ RHS = RHS.getUnqualifiedType();
+ }
Type::TypeClass LHSClass = LHS->getTypeClass();
Type::TypeClass RHSClass = RHS->getTypeClass();
@@ -1655,12 +1661,16 @@ bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) {
if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
// Same as above for arrays
- if (LHSClass == Type::VariableArray) LHSClass = Type::ConstantArray;
- if (RHSClass == Type::VariableArray) RHSClass = Type::ConstantArray;
- if (LHSClass == Type::IncompleteArray) LHSClass = Type::ConstantArray;
- if (RHSClass == Type::IncompleteArray) RHSClass = Type::ConstantArray;
+ if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
+ LHSClass = Type::ConstantArray;
+ if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
+ RHSClass = Type::ConstantArray;
+
+ // Canonicalize OCUVector -> Vector.
+ if (LHSClass == Type::OCUVector) LHSClass = Type::Vector;
+ if (RHSClass == Type::OCUVector) RHSClass = Type::Vector;
- // If the canonical type classes don't match...
+ // If the canonical type classes don't match.
if (LHSClass != RHSClass) {
// For Objective-C, it is possible for two types to be compatible
// when their classes don't match (when dealing with "id"). If either type
@@ -1681,14 +1691,18 @@ bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) {
return false;
}
+
// The canonical type classes match.
switch (LHSClass) {
- case Type::FunctionProto: assert(0 && "Canonicalized away above");
+ case Type::ASQual:
+ case Type::FunctionProto:
+ case Type::VariableArray:
+ case Type::IncompleteArray:
+ case Type::Reference:
+ assert(0 && "Canonicalized away above");
case Type::Pointer:
return pointerTypesAreCompatible(LHS, RHS);
case Type::ConstantArray:
- case Type::VariableArray:
- case Type::IncompleteArray:
return arrayTypesAreCompatible(LHS, RHS);
case Type::FunctionNoProto:
return functionTypesAreCompatible(LHS, RHS);
@@ -1701,7 +1715,6 @@ bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) {
return cast<ObjCInterfaceType>(LHS)->getDecl()->isSuperClassOf(
cast<ObjCInterfaceType>(RHS)->getDecl());
case Type::Vector:
- case Type::OCUVector:
return areCompatVectorTypes(cast<VectorType>(LHS), cast<VectorType>(RHS));
case Type::ObjCQualifiedInterface:
return areCompatObjCQualInterfaces(cast<ObjCQualifiedInterfaceType>(LHS),