2010-05-27 04:19:07 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
|
|
// pr7029
|
|
|
|
|
|
|
|
template <class Key, class T> struct QMap
|
|
|
|
{
|
|
|
|
void insert(const Key &, const T &);
|
|
|
|
T v;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class Key, class T>
|
|
|
|
void QMap<Key, T>::insert(const Key &, const T &avalue)
|
|
|
|
{
|
|
|
|
v = avalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct inotify_event
|
|
|
|
{
|
|
|
|
int wd;
|
|
|
|
|
|
|
|
// clang doesn't like '[]':
|
|
|
|
// cannot initialize a parameter of type 'void *' with an rvalue of type 'char (*)[]'
|
|
|
|
char name [];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void foo()
|
|
|
|
{
|
|
|
|
inotify_event event;
|
|
|
|
inotify_event* ptr = &event;
|
|
|
|
inotify_event event1 = *ptr;
|
|
|
|
*ptr = event;
|
|
|
|
QMap<int, inotify_event> eventForId;
|
|
|
|
eventForId.insert(ptr->wd, *ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct S {
|
2014-01-11 08:53:35 +08:00
|
|
|
virtual void foo();
|
2010-05-27 04:19:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct X {
|
|
|
|
int blah;
|
2014-01-11 08:53:35 +08:00
|
|
|
S strings[];
|
2010-05-27 04:19:07 +08:00
|
|
|
};
|
2010-09-04 05:53:49 +08:00
|
|
|
|
2014-01-11 08:53:35 +08:00
|
|
|
S a, b = a;
|
|
|
|
S f(X &x) {
|
|
|
|
a = b;
|
|
|
|
return x.strings[0];
|
|
|
|
}
|
|
|
|
|
2010-09-04 05:53:49 +08:00
|
|
|
class A {
|
|
|
|
int s;
|
|
|
|
char c[];
|
|
|
|
};
|
|
|
|
|
|
|
|
union B {
|
|
|
|
int s;
|
2011-03-08 04:04:04 +08:00
|
|
|
char c[];
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace rdar9065507 {
|
|
|
|
|
|
|
|
struct StorageBase {
|
|
|
|
long ref_count;
|
|
|
|
unsigned size;
|
|
|
|
unsigned capacity;
|
2010-09-04 05:53:49 +08:00
|
|
|
};
|
2011-03-08 04:04:04 +08:00
|
|
|
|
|
|
|
struct Storage : StorageBase {
|
|
|
|
int data[];
|
|
|
|
};
|
|
|
|
|
2013-11-02 19:19:13 +08:00
|
|
|
struct VirtStorage : virtual StorageBase {
|
|
|
|
int data[]; // expected-error {{flexible array member 'data' not allowed in struct which has a virtual base class}}
|
|
|
|
};
|
|
|
|
|
2011-03-08 04:04:04 +08:00
|
|
|
}
|
2014-01-11 08:53:35 +08:00
|
|
|
|
|
|
|
struct NonTrivDtor { ~NonTrivDtor(); };
|
|
|
|
// FIXME: It's not clear whether we should disallow examples like this. GCC accepts.
|
|
|
|
struct FlexNonTrivDtor {
|
|
|
|
int n;
|
|
|
|
NonTrivDtor ntd[]; // expected-error {{flexible array member 'ntd' of type 'NonTrivDtor []' with non-trivial destruction}}
|
|
|
|
~FlexNonTrivDtor() {
|
|
|
|
for (int i = n; i != 0; --i)
|
|
|
|
ntd[i-1].~NonTrivDtor();
|
|
|
|
}
|
|
|
|
};
|