From 07f352637cc69eb0dbbb56bdb9aa7d5e69085ab9 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 31 Aug 2014 01:33:41 +0000 Subject: [PATCH] Add some negative (and positive) static_assert checks for ArrayRef-of-pointer conversions introduced in r216709 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216830 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/ADT/ArrayRefTest.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/unittests/ADT/ArrayRefTest.cpp b/unittests/ADT/ArrayRefTest.cpp index 649936714f3..f9c98a563fa 100644 --- a/unittests/ADT/ArrayRefTest.cpp +++ b/unittests/ADT/ArrayRefTest.cpp @@ -13,6 +13,23 @@ #include "gtest/gtest.h" using namespace llvm; +// Check that the ArrayRef-of-pointer converting constructor only allows adding +// cv qualifiers (not removing them, or otherwise changing the type) +static_assert( + std::is_convertible, ArrayRef>::value, + "Adding const"); +static_assert( + std::is_convertible, ArrayRef>::value, + "Adding volatile"); +static_assert(!std::is_convertible, ArrayRef>::value, + "Changing pointer of one type to a pointer of another"); +static_assert( + !std::is_convertible, ArrayRef>::value, + "Removing const"); +static_assert( + !std::is_convertible, ArrayRef>::value, + "Removing volatile"); + namespace llvm { TEST(ArrayRefTest, AllocatorCopy) { -- 2.11.0