diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-06-02 20:58:58 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-06-02 20:58:58 +0000 |
commit | 86f4385536a0b2202860ad4e20d84f9330b1a4f4 (patch) | |
tree | 974da355c785d8f602af9de7df83e20c8de21d8e /lib/AST/ASTContext.cpp | |
parent | 8df7a28269a1c0f4444928d0baea402b410e95f1 (diff) |
Diagnose misuse of __strong attribute in a redeclaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72737 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 017d09d265..3b405267e8 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -3033,13 +3033,15 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { if (RHSClass == Type::ExtQual) { QualType::GCAttrTypes GCAttr = RHSCan.getObjCGCAttr(); if (GCAttr != QualType::GCNone) { + QualType::GCAttrTypes GCLHSAttr = LHSCan.getObjCGCAttr(); // __weak attribute must appear on both declarations. - // FIXME. __strong attribue is redundant if other decl is an objective-c - // object pointer (or decorated with __strong attribute). We can't issue - // diagnostic on __strong mismatch becuase 'id' may not be - // available but only with its canonical type at this point. Will - // visit this when 'id' becomes a concrete type. - if (GCAttr == QualType::Weak && LHSCan.getObjCGCAttr() != GCAttr) + // __strong attribue is redundant if other decl is an objective-c + // object pointer (or decorated with __strong attribute); otherwise + // issue error. + if ((GCAttr == QualType::Weak && GCLHSAttr != GCAttr) || + (GCAttr == QualType::Strong && GCLHSAttr != GCAttr && + LHSCan->isPointerType() && !isObjCObjectPointerType(LHSCan) && + !isObjCIdStructType(LHSCan->getAsPointerType()->getPointeeType()))) return QualType(); RHS = QualType(cast<ExtQualType>(RHS.getDesugaredType())->getBaseType(), @@ -3059,10 +3061,15 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { if (GCAttr != QualType::GCNone) { QualType::GCAttrTypes GCRHSAttr = RHSCan.getObjCGCAttr(); // __weak attribute must appear on both declarations. __strong - // attribue is redundant if other decl is an objective-c object pointer. - // See above FIXME comment. - if (GCAttr == QualType::Weak && GCRHSAttr != GCAttr) + // __strong attribue is redundant if other decl is an objective-c + // object pointer (or decorated with __strong attribute); otherwise + // issue error. + if ((GCAttr == QualType::Weak && GCRHSAttr != GCAttr) || + (GCAttr == QualType::Strong && GCRHSAttr != GCAttr && + RHSCan->isPointerType() && !isObjCObjectPointerType(RHSCan) && + !isObjCIdStructType(RHSCan->getAsPointerType()->getPointeeType()))) return QualType(); + LHS = QualType(cast<ExtQualType>(LHS.getDesugaredType())->getBaseType(), LHS.getCVRQualifiers()); QualType Result = mergeTypes(LHS, RHS); |