summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/altivec-init.c
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2009-08-09 17:55:44 +0000
committerNate Begeman <natebegeman@mac.com>2009-08-09 17:55:44 +0000
commita96114ed087b924b9e8c912dacf364d5738666be (patch)
tree149994da557bc5b4cd714afac00666b9ac2a0cfc /clang/test/Sema/altivec-init.c
parentf4c2eee251597e552e83685ba634896aeb390130 (diff)
downloadbcm5719-llvm-a96114ed087b924b9e8c912dacf364d5738666be.tar.gz
bcm5719-llvm-a96114ed087b924b9e8c912dacf364d5738666be.zip
AltiVec-style vector initializer syntax, vec4 a = (vec4)(a, b, c, d);
In addition to being defined by the AltiVec PIM, this is also the vector initializer syntax used by OpenCL, so that vector literals are compatible with macro arguments. llvm-svn: 78535
Diffstat (limited to 'clang/test/Sema/altivec-init.c')
-rw-r--r--clang/test/Sema/altivec-init.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/Sema/altivec-init.c b/clang/test/Sema/altivec-init.c
new file mode 100644
index 00000000000..6185186903b
--- /dev/null
+++ b/clang/test/Sema/altivec-init.c
@@ -0,0 +1,16 @@
+// RUN: clang-cc %s -faltivec -verify -pedantic -fsyntax-only -fblocks=0
+
+typedef int v4 __attribute((vector_size(16)));
+typedef short v8 __attribute((vector_size(16)));
+
+v8 foo(void) {
+ v8 a;
+ v4 b;
+ a = (v8){4, 2}; // expected-error {{too few elements in vector initialization (expected 8 elements, have 2)}}
+ b = (v4)(5, 6, 7, 8, 9); // expected-warning {{excess elements in vector initializer}}
+ b = (v4)(5, 6, 8, 8.0f);
+ return (v8){0, 1, 2, 3, 1, 2, 3, 4};
+
+ // FIXME: test that (type)(fn)(args) still works with -faltivec
+ // FIXME: test that c++ overloaded commas still work -faltivec
+}
OpenPOWER on IntegriCloud