1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2f4a2713aSLionel Sambuc // pr7029 3f4a2713aSLionel Sambuc 4f4a2713aSLionel Sambuc template <class Key, class T> struct QMap 5f4a2713aSLionel Sambuc { 6f4a2713aSLionel Sambuc void insert(const Key &, const T &); 7f4a2713aSLionel Sambuc T v; 8f4a2713aSLionel Sambuc }; 9f4a2713aSLionel Sambuc 10f4a2713aSLionel Sambuc 11f4a2713aSLionel Sambuc template <class Key, class T> insert(const Key &,const T & avalue)12f4a2713aSLionel Sambucvoid QMap<Key, T>::insert(const Key &, const T &avalue) 13f4a2713aSLionel Sambuc { 14f4a2713aSLionel Sambuc v = avalue; 15f4a2713aSLionel Sambuc } 16f4a2713aSLionel Sambuc 17*0a6a1f1dSLionel Sambuc struct Rec { 18*0a6a1f1dSLionel Sambuc union { // expected-warning-re {{variable sized type '{{.*}}' not at the end of a struct or class is a GNU extension}} 19*0a6a1f1dSLionel Sambuc int u0[]; 20*0a6a1f1dSLionel Sambuc }; 21*0a6a1f1dSLionel Sambuc int x; 22*0a6a1f1dSLionel Sambuc } rec; 23f4a2713aSLionel Sambuc 24f4a2713aSLionel Sambuc struct inotify_event 25f4a2713aSLionel Sambuc { 26f4a2713aSLionel Sambuc int wd; 27f4a2713aSLionel Sambuc 28f4a2713aSLionel Sambuc // clang doesn't like '[]': 29f4a2713aSLionel Sambuc // cannot initialize a parameter of type 'void *' with an rvalue of type 'char (*)[]' 30f4a2713aSLionel Sambuc char name []; 31f4a2713aSLionel Sambuc }; 32f4a2713aSLionel Sambuc 33f4a2713aSLionel Sambuc foo()34f4a2713aSLionel Sambucvoid foo() 35f4a2713aSLionel Sambuc { 36f4a2713aSLionel Sambuc inotify_event event; 37f4a2713aSLionel Sambuc inotify_event* ptr = &event; 38f4a2713aSLionel Sambuc inotify_event event1 = *ptr; 39f4a2713aSLionel Sambuc *ptr = event; 40f4a2713aSLionel Sambuc QMap<int, inotify_event> eventForId; 41f4a2713aSLionel Sambuc eventForId.insert(ptr->wd, *ptr); 42f4a2713aSLionel Sambuc } 43f4a2713aSLionel Sambuc 44f4a2713aSLionel Sambuc struct S { 45f4a2713aSLionel Sambuc virtual void foo(); 46f4a2713aSLionel Sambuc }; 47f4a2713aSLionel Sambuc 48f4a2713aSLionel Sambuc struct X { 49f4a2713aSLionel Sambuc int blah; 50*0a6a1f1dSLionel Sambuc S strings[]; 51f4a2713aSLionel Sambuc }; 52f4a2713aSLionel Sambuc 53*0a6a1f1dSLionel Sambuc S a, b = a; f(X & x)54*0a6a1f1dSLionel SambucS f(X &x) { 55*0a6a1f1dSLionel Sambuc a = b; 56*0a6a1f1dSLionel Sambuc return x.strings[0]; 57*0a6a1f1dSLionel Sambuc } 58*0a6a1f1dSLionel Sambuc 59f4a2713aSLionel Sambuc class A { 60f4a2713aSLionel Sambuc int s; 61f4a2713aSLionel Sambuc char c[]; 62f4a2713aSLionel Sambuc }; 63f4a2713aSLionel Sambuc 64f4a2713aSLionel Sambuc union B { 65f4a2713aSLionel Sambuc int s; 66f4a2713aSLionel Sambuc char c[]; 67f4a2713aSLionel Sambuc }; 68f4a2713aSLionel Sambuc 69f4a2713aSLionel Sambuc namespace rdar9065507 { 70f4a2713aSLionel Sambuc 71f4a2713aSLionel Sambuc struct StorageBase { 72f4a2713aSLionel Sambuc long ref_count; 73f4a2713aSLionel Sambuc unsigned size; 74f4a2713aSLionel Sambuc unsigned capacity; 75f4a2713aSLionel Sambuc }; 76f4a2713aSLionel Sambuc 77f4a2713aSLionel Sambuc struct Storage : StorageBase { 78f4a2713aSLionel Sambuc int data[]; 79f4a2713aSLionel Sambuc }; 80f4a2713aSLionel Sambuc 81f4a2713aSLionel Sambuc struct VirtStorage : virtual StorageBase { 82f4a2713aSLionel Sambuc int data[]; // expected-error {{flexible array member 'data' not allowed in struct which has a virtual base class}} 83f4a2713aSLionel Sambuc }; 84f4a2713aSLionel Sambuc 85f4a2713aSLionel Sambuc } 86*0a6a1f1dSLionel Sambuc 87*0a6a1f1dSLionel Sambuc struct NonTrivDtor { ~NonTrivDtor(); }; 88*0a6a1f1dSLionel Sambuc // FIXME: It's not clear whether we should disallow examples like this. GCC accepts. 89*0a6a1f1dSLionel Sambuc struct FlexNonTrivDtor { 90*0a6a1f1dSLionel Sambuc int n; 91*0a6a1f1dSLionel Sambuc NonTrivDtor ntd[]; // expected-error {{flexible array member 'ntd' of type 'NonTrivDtor []' with non-trivial destruction}} ~FlexNonTrivDtorFlexNonTrivDtor92*0a6a1f1dSLionel Sambuc ~FlexNonTrivDtor() { 93*0a6a1f1dSLionel Sambuc for (int i = n; i != 0; --i) 94*0a6a1f1dSLionel Sambuc ntd[i-1].~NonTrivDtor(); 95*0a6a1f1dSLionel Sambuc } 96*0a6a1f1dSLionel Sambuc }; 97