diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2012-10-09 08:18:29 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2012-10-09 06:18:29 +0000 |
commit | a212e43fca22f730987ad4d15a0bd58efae9677e (patch) | |
tree | 41770fbb2dff0d56518b79bce3dd01c52d1b2759 /gcc/testsuite/c-c++-common/scal-to-vec1.c | |
parent | f5220359f4b2ee333e38994e3c275180ff09035f (diff) | |
download | gcc-a212e43fca22f730987ad4d15a0bd58efae9677e.zip gcc-a212e43fca22f730987ad4d15a0bd58efae9677e.tar.gz gcc-a212e43fca22f730987ad4d15a0bd58efae9677e.tar.bz2 |
re PR c++/54427 (Expose more vector extensions)
2012-10-09 Marc Glisse <marc.glisse@inria.fr>
PR c++/54427
c/
* c-typeck.c: Include c-common.h.
(enum stv_conv): Moved to c-common.h.
(scalar_to_vector): Moved to c-common.c.
(build_binary_op): Adapt to scalar_to_vector's new prototype.
* Make-lang.in: c-typeck.c depends on c-common.h.
c-family/
* c-common.c (scalar_to_vector): Moved from c-typeck.c. Support
more operations. Make error messages optional.
* c-common.h (enum stv_conv): Moved from c-typeck.c.
(scalar_to_vector): Declare.
cp/
* typeck.c (cp_build_binary_op): Handle mixed scalar-vector
operations.
[LSHIFT_EXPR, RSHIFT_EXPR]: Likewise.
gcc/
* fold-const.c (fold_binary_loc): Use build_zero_cst instead of
build_int_cst for a potential vector.
testsuite/
* c-c++-common/vector-scalar.c: New testcase.
* g++.dg/ext/vector18.C: New testcase.
* g++.dg/ext/vector5.C: This is not an error anymore.
* gcc.dg/init-vec-1.c: Move ...
* c-c++-common/init-vec-1.c: ... here. Adapt error message.
* gcc.c-torture/execute/vector-shift1.c: Move ...
* c-c++-common/torture/vector-shift1.c: ... here.
* gcc.dg/scal-to-vec1.c: Move ...
* c-c++-common/scal-to-vec1.c: ... here. Avoid narrowing for
C++11. Adapt error messages.
* gcc.dg/convert-vec-1.c: Move ...
* c-c++-common/convert-vec-1.c: ... here.
* gcc.dg/scal-to-vec2.c: Move ...
* c-c++-common/scal-to-vec2.c: ... here.
From-SVN: r192238
Diffstat (limited to 'gcc/testsuite/c-c++-common/scal-to-vec1.c')
-rw-r--r-- | gcc/testsuite/c-c++-common/scal-to-vec1.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/scal-to-vec1.c b/gcc/testsuite/c-c++-common/scal-to-vec1.c new file mode 100644 index 0000000..beb450d --- /dev/null +++ b/gcc/testsuite/c-c++-common/scal-to-vec1.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-long-long" } */ +/* { dg-options "-Wno-long-long -mabi=altivec" { target { { powerpc*-*-linux* } && ilp32 } } } */ + +#define vector(elcount, type) \ +__attribute__((vector_size((elcount)*sizeof(type)))) type + +#define vidx(type, vec, idx) (*((type *) &(vec) + idx)) + + +extern float sfl; +extern int sint; +extern long long sll; + +int main (int argc, char *argv[]) { + vector(8, short) v0 = {(short)argc, 1,2,3,4,5,6,7}; + vector(8, short) v1; + + vector(4, float) f0 = {1., 2., 3., 4.}; + vector(4, float) f1, f2; + + vector(4, int) i0 = {1,2,3,4}; + vector(4, int) i1, i2; + + + int i = 12; + double d = 3.; + + v1 = i + v0; /* { dg-error "conversion of scalar \[^\\n\]* to vector" } */ + v1 = 99999 + v0; /* { dg-error "conversion of scalar \[^\\n\]* to vector" } */ + + f1 = d + f0; /* { dg-error "conversion of scalar \[^\\n\]* to vector" } */ + f1 = 1.3 + f0; /* { dg-error "conversion of scalar \[^\\n\]* to vector" } */ + f1 = sll + f0; /* { dg-error "conversion of scalar \[^\\n\]* to vector" } */ + f1 = ((int)998769576) + f0; /* { dg-error "conversion of scalar \[^\\n\]* to vector" } */ + + /* convert.c should take care of this. */ + i1 = sfl + i0; /* { dg-error "can't convert value to a vector|invalid operands" } */ + i1 = 1.5 + i0; /* { dg-error "can't convert value to a vector|invalid operands" } */ + v1 = d + v0; /* { dg-error "can't convert value to a vector|invalid operands" } */ + + return 0; +} |