aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp
blob: 6a59e3d7ae52617a8787acefe5975ced8d87f400 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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}}
}