[clang] 22c7a6d - [objcxx] Fix `std::addressof` for `id`.
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 8 11:29:44 PDT 2022
Author: zoecarver
Date: 2022-07-08T11:29:30-07:00
New Revision: 22c7a6ddddec6d62e627ca66b886b60ba1ce1e7c
URL: https://github.com/llvm/llvm-project/commit/22c7a6ddddec6d62e627ca66b886b60ba1ce1e7c
DIFF: https://github.com/llvm/llvm-project/commit/22c7a6ddddec6d62e627ca66b886b60ba1ce1e7c.diff
LOG: [objcxx] Fix `std::addressof` for `id`.
Differential Revision: https://reviews.llvm.org/D129384
Added:
clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
Modified:
clang/lib/Sema/SemaChecking.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 4ac3fd38438ca..3ed745c5634c8 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2413,7 +2413,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
bool ReturnsPointer = BuiltinID == Builtin::BIaddressof ||
BuiltinID == Builtin::BI__addressof;
if (!(Param->isReferenceType() &&
- (ReturnsPointer ? Result->isPointerType()
+ (ReturnsPointer ? Result->isAnyPointerType()
: Result->isReferenceType()) &&
Context.hasSameUnqualifiedType(Param->getPointeeType(),
Result->getPointeeType()))) {
diff --git a/clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm b/clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
new file mode 100644
index 0000000000000..a591163714ee5
--- /dev/null
+++ b/clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// expected-no-diagnostics
+
+namespace std {
+ template <class T>
+ T* addressof(T&);
+}
+
+void f(id obj) {
+ (void)std::addressof(*obj);
+}
More information about the cfe-commits
mailing list