aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/flexible-array-test.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-05-26 20:19:07 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-05-26 20:19:07 +0000
commit4142cebf70fe6c3855570c98b8042431797a65fd (patch)
tree1733d6cae4656b2899fa3400d936d7904d5ad994 /test/SemaCXX/flexible-array-test.cpp
parent9d5e5d4c38c5f3fce08d6a5a0cedacfa67c7699f (diff)
Fixes misc. flexible array bugs in c++ (PR7029).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/flexible-array-test.cpp')
-rw-r--r--test/SemaCXX/flexible-array-test.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/SemaCXX/flexible-array-test.cpp b/test/SemaCXX/flexible-array-test.cpp
new file mode 100644
index 0000000000..e58992bc93
--- /dev/null
+++ b/test/SemaCXX/flexible-array-test.cpp
@@ -0,0 +1,45 @@
+// 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 {
+ virtual void foo();
+};
+
+struct X {
+ int blah;
+ S strings[]; // expected-error {{flexible array 'strings' must have a non-dependent, non-POD type}}
+};