OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [bitfld-4.c] - Blame information for rev 414

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

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

powered by: WebSVN 2.1.0

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