summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/expr/expr.unary
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2013-05-06 21:39:12 +0000
committerJohn McCall <rjmccall@apple.com>2013-05-06 21:39:12 +0000
commitd25db7ed0f8ec288a770a75b88caaa688ac22079 (patch)
treed8c43fb8b78535ecf9afca1a38c1eb1a7b68c401 /clang/test/CXX/expr/expr.unary
parent252a0acce2b38dbf23e4e4df47b251cfa2af39aa (diff)
downloadbcm5719-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.unary')
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp b/clang/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp
new file mode 100644
index 00000000000..6a59e3d7ae5
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+ unsigned bitX : 4;
+ unsigned bitY : 4;
+ unsigned var;
+
+ void foo();
+};
+
+void test(A *a) {
+ int x;
+ x = sizeof(a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}}
+ x = sizeof((unsigned) a->bitX);
+ x = sizeof(a->foo(), a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}}
+ x = sizeof(a->var ? a->bitX : a->bitY); // expected-error {{invalid application of 'sizeof' to bit-field}}
+ x = sizeof(a->var ? a->bitX : a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}}
+ x = sizeof(a->bitX = 3); // expected-error {{invalid application of 'sizeof' to bit-field}}
+ x = sizeof(a->bitY += 3); // expected-error {{invalid application of 'sizeof' to bit-field}}
+}
OpenPOWER on IntegriCloud