diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-06-02 01:40:22 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-06-02 01:40:22 +0000 |
commit | 2d725b19da4a3225d2b01e9cf6e9ddc9641cee5a (patch) | |
tree | 05003c03d54fc78a14b81040ff116d3b8eefb709 /clang/lib | |
parent | 836894405f199d0d5cd3dcff98bde891fd683b20 (diff) | |
download | bcm5719-llvm-2d725b19da4a3225d2b01e9cf6e9ddc9641cee5a.tar.gz bcm5719-llvm-2d725b19da4a3225d2b01e9cf6e9ddc9641cee5a.zip |
This patch attempts to fix the merging of __strong/__weak attributes
in merge_types. It is incomplete. We probably want to issue
a warning if user attempts to change the attribute from __weak to
__strong or vice-vera. It also assumes that a __weak/__strong
attribute can not be specified with other (currently one) type
attriute.
llvm-svn: 72711
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a4b9acc110d..28325edbd40 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -3028,6 +3028,20 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto; if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto; + QualType::GCAttrTypes RHSGCAttr = QualType::GCNone; + QualType::GCAttrTypes LHSGCAttr = QualType::GCNone; + if (RHSClass == Type::ExtQual) { + RHSGCAttr = RHSCan.getObjCGCAttr(); + if (RHSGCAttr != QualType::GCNone) + RHSClass = RHSCan.getUnqualifiedType()->getTypeClass(); + } + + if (LHSClass == Type::ExtQual) { + LHSGCAttr = LHSCan.getObjCGCAttr(); + if (LHSGCAttr != QualType::GCNone) + LHSClass = LHSCan.getUnqualifiedType()->getTypeClass(); + } + // Same as above for arrays if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray) LHSClass = Type::ConstantArray; @@ -3125,10 +3139,16 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { QualType RHSPointee = RHS->getAsPointerType()->getPointeeType(); QualType ResultType = mergeTypes(LHSPointee, RHSPointee); if (ResultType.isNull()) return QualType(); - if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType)) + if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType)) { + if (RHSGCAttr != LHSGCAttr && RHSGCAttr != QualType::GCNone) + LHS = getObjCGCQualType(LHS, RHSGCAttr); return LHS; - if (getCanonicalType(RHSPointee) == getCanonicalType(ResultType)) + } + if (getCanonicalType(RHSPointee) == getCanonicalType(ResultType)) { + if (RHSGCAttr != LHSGCAttr && LHSGCAttr != QualType::GCNone) + RHS = getObjCGCQualType(RHS, LHSGCAttr); return RHS; + } return getPointerType(ResultType); } case Type::BlockPointer: |