diff options
author | John McCall <rjmccall@apple.com> | 2013-05-06 21:39:12 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2013-05-06 21:39:12 +0000 |
commit | d25db7ed0f8ec288a770a75b88caaa688ac22079 (patch) | |
tree | d8c43fb8b78535ecf9afca1a38c1eb1a7b68c401 /clang/test/CXX/expr/expr.post/expr.const.cast | |
parent | 252a0acce2b38dbf23e4e4df47b251cfa2af39aa (diff) | |
download | bcm5719-llvm-d25db7ed0f8ec288a770a75b88caaa688ac22079.tar.gz bcm5719-llvm-d25db7ed0f8ec288a770a75b88caaa688ac22079.zip |
Grab-bag of bit-field fixes:
- References to ObjC bit-field ivars are bit-field lvalues;
fixes rdar://13794269, which got me started down this.
- Introduce Expr::refersToBitField, switch a couple users to
it where semantically important, and comment the difference
between this and the existing API.
- Discourage Expr::getBitField by making it a bit longer and
less general-sounding.
- Lock down on const_casts of bit-field gl-values until we
hear back from the committee as to whether they're allowed.
llvm-svn: 181252
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 | 17 |
1 files changed, 16 insertions, 1 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 be898761faf..76ea96fe14a 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 @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics // The result of the expression const_cast<T>(v) is of type T. If T is // an lvalue reference to object type, the result is an lvalue; if T @@ -16,3 +15,19 @@ void test_classification(const int *ptr) { int *ptr1 = const_cast<int *&&>(xvalue<const int*>()); int *ptr2 = const_cast<int *&&>(prvalue<const int*>()); } + +struct A { + volatile unsigned ubf : 4; + volatile unsigned uv; + volatile int sv; + void foo(); + bool pred(); +}; + +void test(A &a) { + unsigned &t0 = const_cast<unsigned&>(a.ubf); // expected-error {{const_cast from bit-field lvalue to reference type}} + unsigned &t1 = const_cast<unsigned&>(a.foo(), a.ubf); // expected-error {{const_cast from bit-field lvalue to reference type}} + unsigned &t2 = const_cast<unsigned&>(a.pred() ? a.ubf : a.ubf); // expected-error {{const_cast from bit-field lvalue to reference type}} + unsigned &t3 = const_cast<unsigned&>(a.pred() ? a.ubf : a.uv); // expected-error {{const_cast from bit-field lvalue to reference type}} + unsigned &t4 = const_cast<unsigned&>(a.pred() ? a.ubf : a.sv); // expected-error {{const_cast from rvalue to reference type}} +} |