OSDN Git Service

PR c++/44148
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / ext / packed3.C
1 // { dg-do compile }
2
3 // Copyright (C) 2003 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 15 Jul 2003 <nathan@codesourcery.com>
5
6 // Packed fields are unsuitable for direct reference binding.
7
8 struct Unpacked { int i; };
9
10 void Ref (int &p);
11 void Ref (Unpacked &p);
12
13 struct  __attribute__ ((packed)) Packed
14 {
15   char c;
16   int i;
17   Unpacked u;
18 };
19
20 void Foo (Packed &p)
21 {
22   Ref (p.i); // { dg-error "cannot bind packed field" "" { target { ! default_packed } } }
23   Ref (p.u.i); // { dg-error "cannot bind packed field" "" { target { ! default_packed } } }
24   Ref (p.u); // { dg-error "cannot bind packed field" "" { target { ! default_packed } } }
25 }