Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc++] Correctly handle Objective-C++ ARC qualifiers in std::is_poi…
…nter Summary: Otherwise, std::is_pointer<id __strong> works, but std::is_pointer<id __weak> (and others) don't work as expected. rdar://problem/49126333 Reviewers: ahatanak, EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D60087 llvm-svn: 357517
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
libcxx/test/libcxx/type_traits/is_pointer_objc.arc.pass.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// UNSUPPORTED: c++98, c++03 | ||
|
||
// <type_traits> | ||
|
||
// std::is_pointer | ||
|
||
// Test that we correctly handle Objective-C++ ARC qualifiers on pointers. | ||
|
||
#include <type_traits> | ||
|
||
|
||
template <typename T> | ||
void test() { | ||
static_assert(std::is_pointer<T __weak>::value, ""); | ||
static_assert(std::is_pointer<T __strong>::value, ""); | ||
static_assert(std::is_pointer<T __autoreleasing>::value, ""); | ||
static_assert(std::is_pointer<T __unsafe_unretained>::value, ""); | ||
|
||
static_assert(std::is_pointer<T __weak const>::value, ""); | ||
static_assert(std::is_pointer<T __strong const>::value, ""); | ||
static_assert(std::is_pointer<T __autoreleasing const>::value, ""); | ||
static_assert(std::is_pointer<T __unsafe_unretained const>::value, ""); | ||
|
||
static_assert(std::is_pointer<T __weak volatile>::value, ""); | ||
static_assert(std::is_pointer<T __strong volatile>::value, ""); | ||
static_assert(std::is_pointer<T __autoreleasing volatile>::value, ""); | ||
static_assert(std::is_pointer<T __unsafe_unretained volatile>::value, ""); | ||
|
||
static_assert(std::is_pointer<T __weak const volatile>::value, ""); | ||
static_assert(std::is_pointer<T __strong const volatile>::value, ""); | ||
static_assert(std::is_pointer<T __autoreleasing const volatile>::value, ""); | ||
static_assert(std::is_pointer<T __unsafe_unretained const volatile>::value, ""); | ||
} | ||
|
||
@class Foo; | ||
|
||
int main(int, char**) { | ||
test<id>(); | ||
test<id const>(); | ||
test<id volatile>(); | ||
test<id const volatile>(); | ||
test<Foo*>(); | ||
test<Foo const*>(); | ||
test<Foo volatile*>(); | ||
test<Foo const volatile*>(); | ||
|
||
return 0; | ||
} |