1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
3 extern void f2(char *);
5 struct __attribute__((packed
)) Arguable
{
11 extern void f3(void());
14 struct __attribute__((packed
)) Arguable
{
21 struct Arguable
*get_arguable();
27 template <typename
... T
>
32 Foo::Arguable arguable
;
33 f1(&arguable
.x
); // expected-warning {{packed member 'x' of class or structure 'Foo::Arguable'}}
34 f2(&arguable
.c
); // no-warning
35 f3(&arguable
.foo
); // no-warning
37 to_void(&arguable
.x
); // no-warning
38 void *p1
= &arguable
.x
; // no-warning
39 void *p2
= static_cast<void *>(&arguable
.x
); // no-warning
40 void *p3
= reinterpret_cast<void *>(&arguable
.x
); // no-warning
41 void *p4
= (void *)&arguable
.x
; // no-warning
46 Arguable
&arguable(arguable1
);
47 f1(&arguable
.x
); // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
48 f2(&arguable
.c
); // no-warning
49 f3(&arguable
.foo
); // no-warning
53 Arguable
*&arguable(arguable1
);
54 f1(&arguable
->x
); // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
55 f2(&arguable
->c
); // no-warning
56 f3(&arguable
->foo
); // no-warning
60 struct __attribute__((packed
)) A
{
65 return &this->x
; // expected-warning {{packed member 'x' of class or structure 'A'}}
69 return &x
; // expected-warning {{packed member 'x' of class or structure 'A'}}
73 return &c
; // no-warning
79 return &this->x
; // expected-warning {{packed member 'x' of class or structure 'A'}}
83 return &x
; // expected-warning {{packed member 'x' of class or structure 'A'}}
87 return &c
; // no-warning
91 template <typename Ty
>
92 class __attribute__((packed
)) S
{
96 const Ty
*get() const {
97 return &X
; // expected-warning {{packed member 'X' of class or structure 'S<int>'}}
98 // expected-warning@-1 {{packed member 'X' of class or structure 'S<float>'}}
102 template <typename Ty
>
107 s1
.get(); // expected-note {{in instantiation of member function 'S<int>::get'}}
113 s3
.get(); // expected-note {{in instantiation of member function 'S<float>::get'}}
121 Incomplete
*e() const;
122 } __attribute__((packed
));
123 Incomplete
*S2::e() const { return (Incomplete
*)&d
; } // no-warning