mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 19:49:36 +00:00
Allow GC qualifiers to be added/removed by conversions from/to void*
without a warning. llvm-svn: 128328
This commit is contained in:
parent
9a624fa993
commit
7853595253
@ -213,6 +213,11 @@ public:
|
||||
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; }
|
||||
|
@ -5803,6 +5803,12 @@ checkPointerTypesForAssignment(Sema &S, QualType lhsType, QualType rhsType) {
|
||||
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;
|
||||
|
@ -17,3 +17,14 @@ static WEAK int h; // expected-warning {{'objc_gc' only applies to pointer types
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user