aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2016-01-27 19:13:42 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2016-01-27 19:13:42 +0000
commitfa74a4bca84aabe0a1500e4fe5359895c1f07e55 (patch)
tree89e14ac50918a33bab845eb73ca1f83e8ad5f26c /gcc/testsuite/c-c++-common
parent0afff540e652c77b409ce094f64cc2b033495785 (diff)
downloadgcc-fa74a4bca84aabe0a1500e4fe5359895c1f07e55.zip
gcc-fa74a4bca84aabe0a1500e4fe5359895c1f07e55.tar.gz
gcc-fa74a4bca84aabe0a1500e4fe5359895c1f07e55.tar.bz2
re PR c/68062 (ICE when comparing vectors)
PR c/68062 * c-typeck.c (build_binary_op) [EQ_EXPR, GE_EXPR]: Promote operand to unsigned, if needed. Add -Wsign-compare warning. * typeck.c (cp_build_binary_op): Promote operand to unsigned, if needed. Add -Wsign-compare warning. * c-c++-common/vector-compare-4.c: New test. From-SVN: r232894
Diffstat (limited to 'gcc/testsuite/c-c++-common')
-rw-r--r--gcc/testsuite/c-c++-common/vector-compare-4.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/vector-compare-4.c b/gcc/testsuite/c-c++-common/vector-compare-4.c
new file mode 100644
index 0000000..b44f474
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/vector-compare-4.c
@@ -0,0 +1,42 @@
+/* PR c/68062 */
+/* { dg-do compile } */
+/* { dg-options "-Wsign-compare" } */
+
+typedef signed char __attribute__ ((vector_size (4))) v4qi;
+typedef unsigned char __attribute__ ((vector_size (4))) uv4qi;
+typedef signed int __attribute__ ((vector_size (4 * __SIZEOF_INT__))) v4si;
+typedef unsigned int __attribute__ ((vector_size (4 * __SIZEOF_INT__))) uv4si;
+
+v4qi
+fn1 (void)
+{
+ v4qi a = { 1, 2, 3, 4 };
+ uv4qi b = { 4, 3, 2, 1 };
+ v4qi v = { 0, 0, 0, 0 };
+
+ v += (a == b); /* { dg-warning "comparison between types" } */
+ v += (a != b); /* { dg-warning "comparison between types" } */
+ v += (a >= b); /* { dg-warning "comparison between types" } */
+ v += (a <= b); /* { dg-warning "comparison between types" } */
+ v += (a > b); /* { dg-warning "comparison between types" } */
+ v += (a < b); /* { dg-warning "comparison between types" } */
+
+ return v;
+}
+
+v4si
+fn2 (void)
+{
+ v4si a = { 1, 2, 3, 4 };
+ uv4si b = { 4, 3, 2, 1 };
+ v4si v = { 0, 0, 0, 0 };
+
+ v += (a == b); /* { dg-warning "comparison between types" } */
+ v += (a != b); /* { dg-warning "comparison between types" } */
+ v += (a >= b); /* { dg-warning "comparison between types" } */
+ v += (a <= b); /* { dg-warning "comparison between types" } */
+ v += (a > b); /* { dg-warning "comparison between types" } */
+ v += (a < b); /* { dg-warning "comparison between types" } */
+
+ return v;
+}