diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-14 22:27:52 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-14 22:27:52 +0000 |
commit | 82c9b5183f97930e8fb146d6b2eece6cb4d24652 (patch) | |
tree | 35e4ca989aed07fd34f3028cda1e1be75754aa52 /clang/test/CXX/expr/expr.post/expr.const.cast | |
parent | ecf9d86404c1f16662cdfb4a3db6c694080b54ed (diff) | |
download | bcm5719-llvm-82c9b5183f97930e8fb146d6b2eece6cb4d24652.tar.gz bcm5719-llvm-82c9b5183f97930e8fb146d6b2eece6cb4d24652.zip |
Fix handling of const_cast from prvalue to rvalue reference: such a cast is
only permitted if the source object is of class type, and should materialize a
temporary for the reference to bind to.
llvm-svn: 184017
Diffstat (limited to 'clang/test/CXX/expr/expr.post/expr.const.cast')
-rw-r--r-- | clang/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp b/clang/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp index 76ea96fe14a..f4c0f1ae122 100644 --- a/clang/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp +++ b/clang/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp @@ -6,14 +6,26 @@ unsigned int f(int); +struct X {}; + template<typename T> T& lvalue(); template<typename T> T&& xvalue(); template<typename T> T prvalue(); -void test_classification(const int *ptr) { - int *ptr0 = const_cast<int *&&>(ptr); - int *ptr1 = const_cast<int *&&>(xvalue<const int*>()); - int *ptr2 = const_cast<int *&&>(prvalue<const int*>()); +void test_classification(const int *ptr, X x) { + int *&&ptr0 = const_cast<int *&&>(ptr); + int *&&ptr1 = const_cast<int *&&>(xvalue<const int*>()); + int *&&ptr2 = const_cast<int *&&>(prvalue<const int*>()); // expected-error {{const_cast from rvalue to reference type 'int *&&'}} + X &&ptr3 = const_cast<X&&>(x); + X &&ptr4 = const_cast<X&&>(xvalue<X>()); + X &&ptr5 = const_cast<X&&>(prvalue<X>()); + + int *&ptr6 = const_cast<int *&>(ptr); + int *&ptr7 = const_cast<int *&>(xvalue<const int*>()); // expected-error {{const_cast from rvalue to reference type 'int *&'}} + int *&ptr8 = const_cast<int *&>(prvalue<const int*>()); // expected-error {{const_cast from rvalue to reference type 'int *&'}} + X &ptr9 = const_cast<X&>(x); + X &ptrA = const_cast<X&>(xvalue<X>()); // expected-error {{const_cast from rvalue to reference type 'X &'}} + X &ptrB = const_cast<X&>(prvalue<X>()); // expected-error {{const_cast from rvalue to reference type 'X &'}} } struct A { |