aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-02-27 23:04:43 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-02-27 23:04:43 +0000
commit5a61f0e5c5aaecd5713c3fa4b78be7167a7eeff2 (patch)
tree05e84af1dde9e07d7ab898d4ffac2176fc2ab871 /lib
parentc136e6cf237711f9f1324637a0b2cdf6ae8e79e4 (diff)
Fix enumeration in switch warnings, plus misc comment changes. No
behavior change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65658 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ASTContext.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index e4347d53db..702dba2431 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -798,6 +798,8 @@ QualType ASTContext::getObjCGCQualType(QualType T,
// If the base type isn't canonical, this won't be a canonical type either,
// so fill in the canonical type field.
+ // FIXME: Isn't this also not canonical if the base type is a array
+ // or pointer type? I can't find any documentation for objc_gc, though...
QualType Canonical;
if (!T->isCanonical()) {
Canonical = getObjCGCQualType(CanT, GCAttr);
@@ -2667,8 +2669,9 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
return LHS;
// If the qualifiers are different, the types aren't compatible
- if (LHSCan.getCVRQualifiers() != RHSCan.getCVRQualifiers() ||
- LHSCan.getAddressSpace() != RHSCan.getAddressSpace())
+ // Note that we handle extended qualifiers later, in the
+ // case for ExtQualType.
+ if (LHSCan.getCVRQualifiers() != RHSCan.getCVRQualifiers())
return QualType();
Type::TypeClass LHSClass = LHSCan->getTypeClass();
@@ -2851,11 +2854,14 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
// Distinct complex types are incompatible.
return QualType();
case Type::Vector:
+ // FIXME: The merged type should be an ExtVector!
if (areCompatVectorTypes(LHS->getAsVectorType(), RHS->getAsVectorType()))
return LHS;
return QualType();
case Type::ObjCInterface: {
// Check if the interfaces are assignment compatible.
+ // FIXME: This should be type compatibility, e.g. whether
+ // "LHS x; RHS x;" at global scope is legal.
const ObjCInterfaceType* LHSIface = LHS->getAsObjCInterfaceType();
const ObjCInterfaceType* RHSIface = RHS->getAsObjCInterfaceType();
if (LHSIface && RHSIface &&
@@ -2867,6 +2873,39 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
case Type::ObjCQualifiedId:
// Distinct qualified id's are not compatible.
return QualType();
+ case Type::FixedWidthInt:
+ // Distinct fixed-width integers are not compatible.
+ return QualType();
+ case Type::ObjCQualifiedClass:
+ // Distinct qualified classes are not compatible.
+ return QualType();
+ case Type::ExtQual:
+ // FIXME: ExtQual types can be compatible even if they're not
+ // identical!
+ return QualType();
+ // First attempt at an implementation, but I'm not really sure it's
+ // right...
+#if 0
+ ExtQualType* LQual = cast<ExtQualType>(LHSCan);
+ ExtQualType* RQual = cast<ExtQualType>(RHSCan);
+ if (LQual->getAddressSpace() != RQual->getAddressSpace() ||
+ LQual->getObjCGCAttr() != RQual->getObjCGCAttr())
+ return QualType();
+ QualType LHSBase, RHSBase, ResultType, ResCanUnqual;
+ LHSBase = QualType(LQual->getBaseType(), 0);
+ RHSBase = QualType(RQual->getBaseType(), 0);
+ ResultType = mergeTypes(LHSBase, RHSBase);
+ if (ResultType.isNull()) return QualType();
+ ResCanUnqual = getCanonicalType(ResultType).getUnqualifiedType();
+ if (LHSCan.getUnqualifiedType() == ResCanUnqual)
+ return LHS;
+ if (RHSCan.getUnqualifiedType() == ResCanUnqual)
+ return RHS;
+ ResultType = getAddrSpaceQualType(ResultType, LQual->getAddressSpace());
+ ResultType = getObjCGCQualType(ResultType, LQual->getObjCGCAttr());
+ ResultType.setCVRQualifiers(LHSCan.getCVRQualifiers());
+ return ResultType;
+#endif
}
return QualType();