From d381cde486ae31e91282d04bc2104e9fd2b9853c Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Sat, 11 Apr 2009 00:00:54 +0000 Subject: [PATCH] Non-pointer objects are none gc'able regardles of the attribute set on them. llvm-svn: 68844 --- clang/lib/AST/ASTContext.cpp | 4 ++++ clang/test/CodeGenObjC/objc2-no-strong-cast.m | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 clang/test/CodeGenObjC/objc2-no-strong-cast.m diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 25ab97e7c7ec..ac69a38c3dcf 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2694,6 +2694,10 @@ QualType::GCAttrTypes ASTContext::getObjCGCAttrKind(const QualType &Ty) const { else if (Ty->isPointerType()) return getObjCGCAttrKind(Ty->getAsPointerType()->getPointeeType()); } + // Non-pointers have none gc'able attribute regardless of the attribute + // set on them. + else if (!isObjCObjectPointerType(Ty) && !Ty->isPointerType()) + return QualType::GCNone; } return GCAttrs; } diff --git a/clang/test/CodeGenObjC/objc2-no-strong-cast.m b/clang/test/CodeGenObjC/objc2-no-strong-cast.m new file mode 100644 index 000000000000..bce50cd4544c --- /dev/null +++ b/clang/test/CodeGenObjC/objc2-no-strong-cast.m @@ -0,0 +1,22 @@ +// RUN: clang-cc -emit-llvm -o %t %s + +@interface PDFViewPrivateVars +{ +@public + __attribute__((objc_gc(strong))) char *addedTooltips; +} +@end + +@interface PDFView +{ + PDFViewPrivateVars *_pdfPriv; +} +@end + +@implementation PDFView +- (void) addTooltipsForPage +{ + _pdfPriv->addedTooltips[4] = 1; +} +@end +