summaryrefslogtreecommitdiffstats
path: root/llvm/test/CFrontend/bit-accurate-int.c
blob: a2138bc7d26f089672d02289f20eb81e6298300a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// RUN: %llvmgcc -S %s -o - /dev/null
// XFAIL: *

#define ATTR_BITS(N) __attribute__((bitwidth(N))) 

typedef int ATTR_BITS( 4) My04BitInt;
typedef int ATTR_BITS(16) My16BitInt;
typedef int ATTR_BITS(17) My17BitInt;
typedef int ATTR_BITS(37) My37BitInt;
typedef int ATTR_BITS(65) My65BitInt;

struct MyStruct {
  My04BitInt i4Field;
  short ATTR_BITS(12) i12Field;
  long ATTR_BITS(17) i17Field;
  My37BitInt i37Field;
};

My37BitInt doit( short ATTR_BITS(23) num) {
  My17BitInt i;
  struct MyStruct strct;
  int bitsize1 = sizeof(My17BitInt);
  int __attribute__((bitwidth(9))) j;
  int bitsize2 = sizeof(j);
  int result = bitsize1 + bitsize2;
  strct.i17Field = result;
  result += sizeof(struct MyStruct);
  return result;
}

int
main ( int argc, char** argv)
{
  return (int ATTR_BITS(32)) doit((short ATTR_BITS(23))argc);
}
OpenPOWER on IntegriCloud