summaryrefslogtreecommitdiff
path: root/test/CXX
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-07-18 20:13:36 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-07-18 20:13:36 +0000
commit580f7daabc7696d50ad09d9643b2afeadbd387d8 (patch)
tree90caa25f363575e23215c43ece336ca7b88061d1 /test/CXX
parent1a78aeb17c78bc38c5cc7580dccc49136079ac07 (diff)
downloadclang-580f7daabc7696d50ad09d9643b2afeadbd387d8.tar.gz
DR330: when determining whether a cast casts away constness, consider
qualifiers from all levels matching a multidimensional array. For example, this allows casting from pointer to array of array of const volatile int to pointer to const pointer to volatile pointer to int because the multidimensional array part of the source type corresponds to a part of the destination type that contains both 'const' and 'volatile'. Differential Revision: https://reviews.llvm.org/D49457 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX')
-rw-r--r--test/CXX/drs/dr3xx.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/CXX/drs/dr3xx.cpp b/test/CXX/drs/dr3xx.cpp
index 04fd258a7c..d723c5b78c 100644
--- a/test/CXX/drs/dr3xx.cpp
+++ b/test/CXX/drs/dr3xx.cpp
@@ -403,6 +403,28 @@ namespace dr330 { // dr330: 7
(void) reinterpret_cast<T>(q); // expected-error {{casts away qualifiers}}
(void) reinterpret_cast<Q>(t);
}
+
+ namespace swift_17882 {
+ typedef const char P[72];
+ typedef int *Q;
+ void f(P &pr, P *pp) {
+ (void) reinterpret_cast<const Q&>(pr);
+ (void) reinterpret_cast<const Q*>(pp);
+ }
+
+ struct X {};
+ typedef const volatile int A[1][2][3];
+ typedef int *const X::*volatile *B1;
+ typedef int *const X::* *B2;
+ typedef int *X::* volatile *B3;
+ typedef volatile int *(*const B4)[4];
+ void f(A *a) {
+ (void) reinterpret_cast<B1*>(a);
+ (void) reinterpret_cast<B2*>(a); // expected-error {{casts away qualifiers}}
+ (void) reinterpret_cast<B3*>(a); // expected-error {{casts away qualifiers}}
+ (void) reinterpret_cast<B4*>(a);
+ }
+ }
}
namespace dr331 { // dr331: yes