svn merge -r102224:107263 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_4-branch
[official-gcc.git] / gcc / testsuite / gcc.dg / bitfld-2.c
blobd3096a7caa8656f63161f61c4d1366b6a4bb716d
1 /* Copyright (C) 2002 Free Software Foundation, Inc.
3 Tests we warn about overly-large assignments to bitfields.
5 Source: Neil Booth, 28 Jan 2002.
6 */
8 struct bf
10 unsigned int a: 2;
11 int b: 2;
14 struct bf p = {4, 0}; /* { dg-warning "truncated" "" { xfail *-*-* } } */
15 struct bf q = {0, 2}; /* { dg-warning "overflow" "" { xfail *-*-* } } */
16 struct bf r = {3, -2}; /* { dg-bogus "(truncated|overflow)" } */
18 void foo ()
20 p.a = 4, p.b = 0; /* { dg-warning "truncated" "" { xfail *-*-* } } */
21 q.a = 0, q.b = 2; /* { dg-warning "overflow" "" { xfail *-*-* } } */
22 r.a = 3, r.b = -2; /* { dg-bogus "(truncated|overflow)" } */