aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/abi/bitfield1.C
blob: d5d04bcd73a99a5ec7c8b76e790756c24c6bb86b (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
// { dg-do run }
// { dg-options "-ansi -pedantic-errors -funsigned-bitfields" }

// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 15 Dec 2001 <nathan@codesourcery.com>

typedef int Int;
typedef signed int SInt;
typedef unsigned int UInt;

struct A
{
  SInt bitS : 1;	// signed
  UInt bitU : 1;	// unsigned
  Int bit : 1;		// signedness by -f{signed,unsigned}-bitfields
};

int main ()
{
  A a;

  a.bitS = 1; // { dg-warning "overflow" }
  a.bitU = 1;
  a.bit = 1;

  if (a.bitS != -1)
    return 1;
  if (a.bitU != 1)
    return 2;
  if (a.bit != 1)
    return 3;

  return 0;
}