[PATCH] D89475: [SemaObjC] Fix composite pointer type calculation for `void*` and pointer to lifetime qualified ObjC pointer type
Erik Pilkington via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 15 08:18:30 PDT 2020
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, rjmccall.
Herald added subscribers: ributzka, dexonsmith, jkorous.
erik.pilkington requested review of this revision.
This fixes a regression introduced in 9a6f4d451ca7aa06b94a407015fbadb456bc09ef <https://reviews.llvm.org/rG9a6f4d451ca7aa06b94a407015fbadb456bc09ef>:
void f() {
NSString *__strong* sptr;
void *vptr;
vptr == sptr; // new error: incompatible pointer types
}
We're now erroring out on this code because `FindCompositePointerType` is rejecting the qualifier mismatch between `void` and `NSString *__strong` after stripping one level of pointer types.
rdar://70101809
https://reviews.llvm.org/D89475
Files:
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaObjCXX/arc-ptr-comparison.mm
Index: clang/test/SemaObjCXX/arc-ptr-comparison.mm
===================================================================
--- clang/test/SemaObjCXX/arc-ptr-comparison.mm
+++ clang/test/SemaObjCXX/arc-ptr-comparison.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -verify %s
// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -verify -DNOARC %s
#ifdef NOARC
// expected-no-diagnostics
@@ -51,3 +51,17 @@
return a == cv;
return ca == v;
}
+
+#ifndef NOARC
+int testDoublePtr(void *pv, void **ppv, A *__strong* pspa, A *__weak* pwpa, A *__strong** ppspa) {
+ return pv == pspa;
+ return pspa == pv;
+ return pv == pspa;
+ return pv == pwpa;
+ return pspa == pwpa; // expected-error {{comparison of distinct pointer types}}
+ return ppv == pspa; // expected-error {{comparison of distinct pointer types}}
+ return pspa == ppv; // expected-error {{comparison of distinct pointer types}}
+ return pv == ppspa;
+ return ppv == ppspa; // expected-error{{comparison of distinct pointer types}}
+}
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6552,12 +6552,16 @@
// FIXME: In C, we merge __strong and none to __strong at the top level.
if (Q1.getObjCGCAttr() == Q2.getObjCGCAttr())
Quals.setObjCGCAttr(Q1.getObjCGCAttr());
+ else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+ assert(Steps.size() == 1);
else
return QualType();
// Mismatched lifetime qualifiers never compatibly include each other.
if (Q1.getObjCLifetime() == Q2.getObjCLifetime())
Quals.setObjCLifetime(Q1.getObjCLifetime());
+ else if (T1->isVoidPointerType() || T2->isVoidPointerType())
+ assert(Steps.size() == 1);
else
return QualType();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89475.298389.patch
Type: text/x-patch
Size: 2077 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201015/1fd692d8/attachment.bin>
More information about the cfe-commits
mailing list