Richard Smith | f63eee7 | 2012-05-09 18:56:43 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -faltivec -fno-lax-vector-conversions -triple powerpc-unknown-unknown -fcxx-exceptions -verify %s |
Douglas Gregor | 255210e | 2010-08-06 10:14:59 +0000 | [diff] [blame] | 2 | |
| 3 | typedef int V4i __attribute__((vector_size(16))); |
| 4 | |
Anton Yartsev | e5da3e6 | 2011-03-19 07:53:43 +0000 | [diff] [blame] | 5 | void test_vec_step(vector short arg1) { |
| 6 | vector bool char vbc; |
| 7 | vector signed char vsc; |
| 8 | vector unsigned char vuc; |
| 9 | vector bool short vbs; |
| 10 | vector short vs; |
| 11 | vector unsigned short vus; |
| 12 | vector pixel vp; |
| 13 | vector bool int vbi; |
| 14 | vector int vi; |
| 15 | vector unsigned int vui; |
| 16 | vector float vf; |
| 17 | |
| 18 | vector int *pvi; |
| 19 | |
| 20 | int res1[vec_step(arg1) == 8 ? 1 : -1]; |
| 21 | int res2[vec_step(vbc) == 16 ? 1 : -1]; |
| 22 | int res3[vec_step(vsc) == 16 ? 1 : -1]; |
| 23 | int res4[vec_step(vuc) == 16 ? 1 : -1]; |
| 24 | int res5[vec_step(vbs) == 8 ? 1 : -1]; |
| 25 | int res6[vec_step(vs) == 8 ? 1 : -1]; |
| 26 | int res7[vec_step(vus) == 8 ? 1 : -1]; |
| 27 | int res8[vec_step(vp) == 8 ? 1 : -1]; |
| 28 | int res9[vec_step(vbi) == 4 ? 1 : -1]; |
| 29 | int res10[vec_step(vi) == 4 ? 1 : -1]; |
| 30 | int res11[vec_step(vui) == 4 ? 1 : -1]; |
| 31 | int res12[vec_step(vf) == 4 ? 1 : -1]; |
| 32 | int res13[vec_step(*pvi) == 4 ? 1 : -1]; |
| 33 | } |
| 34 | |
Douglas Gregor | 255210e | 2010-08-06 10:14:59 +0000 | [diff] [blame] | 35 | void f(V4i a) |
| 36 | { |
| 37 | } |
| 38 | |
Anton Yartsev | 683564a | 2011-02-07 02:17:30 +0000 | [diff] [blame] | 39 | void test1() |
Douglas Gregor | 255210e | 2010-08-06 10:14:59 +0000 | [diff] [blame] | 40 | { |
| 41 | V4i vGCC; |
| 42 | vector int vAltiVec; |
| 43 | |
| 44 | f(vAltiVec); |
| 45 | vGCC = vAltiVec; |
Anton Yartsev | aa4fe05 | 2010-11-18 03:19:30 +0000 | [diff] [blame] | 46 | bool res = vGCC > vAltiVec; |
Douglas Gregor | 255210e | 2010-08-06 10:14:59 +0000 | [diff] [blame] | 47 | vAltiVec = 0 ? vGCC : vGCC; |
| 48 | } |
Anton Yartsev | 683564a | 2011-02-07 02:17:30 +0000 | [diff] [blame] | 49 | |
| 50 | template<typename T> |
| 51 | void template_f(T param) { |
| 52 | param++; |
| 53 | } |
| 54 | |
| 55 | void test2() |
| 56 | { |
| 57 | vector int vi; |
| 58 | ++vi; |
| 59 | vi++; |
| 60 | --vi; |
| 61 | vi--; |
| 62 | vector float vf; |
| 63 | vf++; |
| 64 | |
Richard Smith | 6c3af3d | 2013-01-17 01:17:56 +0000 | [diff] [blame] | 65 | ++vi=vi; // expected-warning {{unsequenced}} |
Anton Yartsev | 683564a | 2011-02-07 02:17:30 +0000 | [diff] [blame] | 66 | (++vi)[1]=1; |
| 67 | template_f(vi); |
| 68 | } |
Richard Smith | 61ffd09 | 2011-10-27 23:31:58 +0000 | [diff] [blame] | 69 | |
| 70 | namespace LValueToRValueConversions { |
| 71 | struct Struct { |
| 72 | float f(); |
| 73 | int n(); |
| 74 | }; |
| 75 | |
| 76 | vector float initFloat = (vector float)(Struct().f); // expected-error {{did you mean to call it}} |
| 77 | vector int initInt = (vector int)(Struct().n); // expected-error {{did you mean to call it}} |
| 78 | } |
Richard Smith | f63eee7 | 2012-05-09 18:56:43 +0000 | [diff] [blame] | 79 | |
| 80 | void f() { |
| 81 | try {} |
| 82 | catch (vector pixel px) {} |
| 83 | }; |