OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [abi/] [bitfield4.C] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-do run { target { pcc_bitfield_type_matters || default_packed } } } */
2
 
3
/* Check bitfields and non-bitfields are aligned & sized similarly.
4
 
5
   Copyright (C) 2002 Free Software Foundation Inc
6
   Contributed by Nathan Sidwell 
7
*/
8
 
9
#include 
10
#include 
11
 
12
static int fail;
13
 
14
#define CHECK1(N, T) do { \
15
  typedef struct Field_##N { char c; T f; } Field_##N; \
16
  typedef struct BitField_##N { char c; T f : sizeof (T) * CHAR_BIT; } BitField_##N; \
17
  if (sizeof (Field_##N) != sizeof (BitField_##N)) { \
18
    fail = 1; printf ("sizeof %s failed\n", #T); \
19
  } \
20
  if (__alignof__ (Field_##N) != __alignof__ (BitField_##N)) { \
21
    fail = 1; printf ("__alignof__ %s failed\n", #T); \
22
  } \
23
} while (0)
24
 
25
#define CHECK(N, T) do { \
26
  CHECK1(N, T); \
27
  CHECK1 (s##N, signed T); \
28
  CHECK1 (u##N, unsigned T); \
29
} while (0)
30
 
31
int main ()
32
{
33
 
34
  CHECK (c, char);
35
  CHECK (s, short);
36
  CHECK (i, int);
37
  CHECK (l, long);
38
  CHECK (ll, long long);
39
 
40
  return fail;
41
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.