[llvm] r216830 - Add some negative (and positive) static_assert checks for ArrayRef-of-pointer conversions introduced in r216709
David Blaikie
dblaikie at gmail.com
Sat Aug 30 18:33:41 PDT 2014
Author: dblaikie
Date: Sat Aug 30 20:33:41 2014
New Revision: 216830
URL: http://llvm.org/viewvc/llvm-project?rev=216830&view=rev
Log:
Add some negative (and positive) static_assert checks for ArrayRef-of-pointer conversions introduced in r216709
Modified:
llvm/trunk/unittests/ADT/ArrayRefTest.cpp
Modified: llvm/trunk/unittests/ADT/ArrayRefTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/ArrayRefTest.cpp?rev=216830&r1=216829&r2=216830&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/ArrayRefTest.cpp (original)
+++ llvm/trunk/unittests/ADT/ArrayRefTest.cpp Sat Aug 30 20:33:41 2014
@@ -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<int *>, ArrayRef<const int *>>::value,
+ "Adding const");
+static_assert(
+ std::is_convertible<ArrayRef<int *>, ArrayRef<volatile int *>>::value,
+ "Adding volatile");
+static_assert(!std::is_convertible<ArrayRef<int *>, ArrayRef<float *>>::value,
+ "Changing pointer of one type to a pointer of another");
+static_assert(
+ !std::is_convertible<ArrayRef<const int *>, ArrayRef<int *>>::value,
+ "Removing const");
+static_assert(
+ !std::is_convertible<ArrayRef<volatile int *>, ArrayRef<int *>>::value,
+ "Removing volatile");
+
namespace llvm {
TEST(ArrayRefTest, AllocatorCopy) {
More information about the llvm-commits
mailing list