[cfe-commits] r128328 - in /cfe/trunk: include/clang/AST/Type.h lib/Sema/SemaExpr.cpp test/SemaObjC/attr-objc-gc.m
John McCall
rjmccall at apple.com
Fri Mar 25 19:56:45 PDT 2011
Author: rjmccall
Date: Fri Mar 25 21:56:45 2011
New Revision: 128328
URL: http://llvm.org/viewvc/llvm-project?rev=128328&view=rev
Log:
Allow GC qualifiers to be added/removed by conversions from/to void*
without a warning.
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/attr-objc-gc.m
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=128328&r1=128327&r2=128328&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Fri Mar 25 21:56:45 2011
@@ -213,6 +213,11 @@
assert(type);
setObjCGCAttr(type);
}
+ Qualifiers withoutObjCGCAttr() const {
+ Qualifiers qs = *this;
+ qs.removeObjCGCAttr();
+ return qs;
+ }
bool hasAddressSpace() const { return Mask & AddressSpaceMask; }
unsigned getAddressSpace() const { return Mask >> AddressSpaceShift; }
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=128328&r1=128327&r2=128328&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Mar 25 21:56:45 2011
@@ -5803,6 +5803,12 @@
if (lhq.getAddressSpace() != rhq.getAddressSpace())
ConvTy = Sema::IncompatiblePointerDiscardsQualifiers;
+ // It's okay to add or remove GC qualifiers when converting to
+ // and from void*.
+ else if (lhq.withoutObjCGCAttr().compatiblyIncludes(rhq.withoutObjCGCAttr())
+ && (lhptee->isVoidType() || rhptee->isVoidType()))
+ ; // keep old
+
// For GCC compatibility, other qualifier mismatches are treated
// as still compatible in C.
else ConvTy = Sema::CompatiblePointerDiscardsQualifiers;
Modified: cfe/trunk/test/SemaObjC/attr-objc-gc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-objc-gc.m?rev=128328&r1=128327&r2=128328&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-objc-gc.m (original)
+++ cfe/trunk/test/SemaObjC/attr-objc-gc.m Fri Mar 25 21:56:45 2011
@@ -17,3 +17,14 @@
/* expected-warning {{'__weak' only applies to pointer types; type here is 'int'}}*/ static __we\
ak int i;
+
+// rdar://problem/9126213
+void test2(id __attribute((objc_gc(strong))) *strong,
+ id __attribute((objc_gc(weak))) *weak) {
+ void *opaque;
+ opaque = strong;
+ strong = opaque;
+
+ opaque = weak;
+ weak = opaque;
+}
More information about the cfe-commits
mailing list