c-common.h (same_scalar_type_ignoring_signedness): Protoize.
* c-common.h (same_scalar_type_ignoring_signedness): Protoize. * c-common.c (same_scalar_type_ignoring_signedness): New. * c-typeck.c (build_binary_op): Check compatability of vector types. Move error report after switch. Do not clobber code[01] on *_DIV_EXPR case. * testsuite/gcc.dg/simd-1.c: Update error messages. * testsuite/gcc.dg/simd-1b.c: Re-enable tests. Update error messages. * testsuite/gcc.dg/simd-2.c: Update error messages. * testsuite/gcc.dg/simd-4.c: New. From-SVN: r100976
This commit is contained in:
parent
d7f88d8648
commit
5bed876a02
|
@ -1,3 +1,19 @@
|
|||
2005-06-15 Aldy Hernandez <aldyh@redhat.com>
|
||||
|
||||
* c-common.h (same_scalar_type_ignoring_signedness): Protoize.
|
||||
|
||||
* c-common.c (same_scalar_type_ignoring_signedness): New.
|
||||
|
||||
* c-typeck.c (build_binary_op): Check compatability of vector
|
||||
types. Move error report after switch.
|
||||
Do not clobber code[01] on *_DIV_EXPR case.
|
||||
|
||||
* testsuite/gcc.dg/simd-1.c: Update error messages.
|
||||
* testsuite/gcc.dg/simd-1b.c: Re-enable tests. Update error
|
||||
messages.
|
||||
* testsuite/gcc.dg/simd-2.c: Update error messages.
|
||||
* testsuite/gcc.dg/simd-4.c: New.
|
||||
|
||||
2005-06-15 Bernd Schmidt <bernd.schmidt@analog.com>
|
||||
|
||||
* Makefile.in (local-alloc.o): Depend on $(GGC_H) and reload.h.
|
||||
|
|
|
@ -6030,4 +6030,19 @@ resolve_overloaded_builtin (tree function, tree params)
|
|||
}
|
||||
}
|
||||
|
||||
/* Ignoring their sign, return true if two scalar types are the same. */
|
||||
bool
|
||||
same_scalar_type_ignoring_signedness (tree t1, tree t2)
|
||||
{
|
||||
enum tree_code c1 = TREE_CODE (t1), c2 = TREE_CODE (t2);
|
||||
|
||||
gcc_assert ((c1 == INTEGER_TYPE || c1 == REAL_TYPE)
|
||||
&& (c2 == INTEGER_TYPE || c2 == REAL_TYPE));
|
||||
|
||||
/* Equality works here because c_common_signed_type uses
|
||||
TYPE_MAIN_VARIANT. */
|
||||
return lang_hooks.types.signed_type (t1)
|
||||
== lang_hooks.types.signed_type (t2);
|
||||
}
|
||||
|
||||
#include "gt-c-common.h"
|
||||
|
|
|
@ -657,6 +657,7 @@ extern tree convert_and_check (tree, tree);
|
|||
extern void overflow_warning (tree);
|
||||
extern void unsigned_conversion_warning (tree, tree);
|
||||
extern bool c_determine_visibility (tree);
|
||||
extern bool same_scalar_type_ignoring_signedness (tree, tree);
|
||||
|
||||
#define c_sizeof(T) c_sizeof_or_alignof_type (T, true, 1)
|
||||
#define c_alignof(T) c_sizeof_or_alignof_type (T, false, 1)
|
||||
|
|
|
@ -7548,12 +7548,14 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
|
|||
&& (code1 == INTEGER_TYPE || code1 == REAL_TYPE
|
||||
|| code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE))
|
||||
{
|
||||
if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
|
||||
code0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
|
||||
if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
|
||||
code1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
|
||||
enum tree_code tcode0 = code0, tcode1 = code1;
|
||||
|
||||
if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE))
|
||||
if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
|
||||
tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
|
||||
if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
|
||||
tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
|
||||
|
||||
if (!(tcode0 == INTEGER_TYPE && tcode1 == INTEGER_TYPE))
|
||||
resultcode = RDIV_EXPR;
|
||||
else
|
||||
/* Although it would be tempting to shorten always here, that
|
||||
|
@ -7793,6 +7795,15 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
|
|||
if (code0 == ERROR_MARK || code1 == ERROR_MARK)
|
||||
return error_mark_node;
|
||||
|
||||
if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE
|
||||
&& (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1))
|
||||
|| !same_scalar_type_ignoring_signedness (TREE_TYPE (type0),
|
||||
TREE_TYPE (type1))))
|
||||
{
|
||||
binary_op_error (code);
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
|
||||
|| code0 == VECTOR_TYPE)
|
||||
&&
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2005-06-15 Aldy Hernandez <aldyh@redhat.com>
|
||||
|
||||
* gcc.dg/simd-1.c: Update error messages.
|
||||
* gcc.dg/simd-1b.c: Re-enable tests. Update error messages.
|
||||
* gcc.dg/simd-2.c: Update error messages.
|
||||
* gcc.dg/simd-4.c: New.
|
||||
|
||||
2005-06-15 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
PR c++/20678
|
||||
|
|
|
@ -54,8 +54,8 @@ hanneke ()
|
|||
a = -b;
|
||||
|
||||
/* Operators on incompatible SIMD types. */
|
||||
a = b + c; /* { dg-error "can't convert between vector values of different size" } */
|
||||
a = b - c; /* { dg-error "can't convert between vector values of different size" } */
|
||||
a = b * c; /* { dg-error "can't convert between vector values of different size" } */
|
||||
a = b / c; /* { dg-error "can't convert between vector values of different size" } */
|
||||
a = b + c; /* { dg-error "invalid operands to binary +" } */
|
||||
a = b - c; /* { dg-error "invalid operands to binary -" } */
|
||||
a = b * c; /* { dg-error "invalid operands to binary *" } */
|
||||
a = b / c; /* { dg-error "invalid operands to binary /" } */
|
||||
}
|
||||
|
|
|
@ -14,23 +14,23 @@ void
|
|||
hanneke ()
|
||||
{
|
||||
/* Operators on compatible SIMD types. */
|
||||
a %= b; /* { dg-bogus "invalid operands to binary %" "" { xfail *-*-* } } */
|
||||
a %= b; /* { dg-error "invalid operands to binary %" } */
|
||||
c &= d;
|
||||
a |= b;
|
||||
c ^= d;
|
||||
a >>= b; /* { dg-bogus "invalid operands to binary >>" "" { xfail *-*-* } } */
|
||||
c <<= d; /* { dg-bogus "invalid operands to binary <<" "" { xfail *-*-* } } */
|
||||
a >>= b; /* { dg-error "invalid operands to binary >>" } */
|
||||
c <<= d; /* { dg-error "invalid operands to binary <<" } */
|
||||
a = +b;
|
||||
c = ~d;
|
||||
|
||||
/* Operators on incompatible SIMD types. */
|
||||
/* a = b % c; { dg*error "can't convert between vector values of different size" } */
|
||||
a = b % c; /* { dg-bogus "invalid operands to binary %" "" { xfail *-*-* } } */
|
||||
d = c & b; /* { dg-error "can't convert between vector values of different size" } */
|
||||
a = b | c; /* { dg-error "can't convert between vector values of different size" } */
|
||||
d = c ^ b; /* { dg-error "can't convert between vector values of different size" } */
|
||||
/* a = b >> c; { dg*error "can't convert between vector values of different size" } */
|
||||
a = b >> c; /* { dg-bogus "invalid operands to binary >>" "" { xfail *-*-* } } */
|
||||
/* d = c << b; { dg*error "can't convert between vector values of different size" } */
|
||||
d = c << b; /* { dg-bogus "invalid operands to binary <<" "" { xfail *-*-* } } */
|
||||
a = b % c; /* { dg-error "invalid operands to binary" } */
|
||||
a = b % c; /* { dg-error "invalid operands to binary" } */
|
||||
d = c & b; /* { dg-error "invalid operands to binary" } */
|
||||
a = b | c; /* { dg-error "invalid operands to binary" } */
|
||||
d = c ^ b; /* { dg-error "invalid operands to binary" } */
|
||||
a = b >> c; /* { dg-error "invalid operands to binary" } */
|
||||
a = b >> c; /* { dg-error "invalid operands to binary" } */
|
||||
d = c << b; /* { dg-error "invalid operands to binary" } */
|
||||
d = c << b; /* { dg-error "invalid operands to binary" } */
|
||||
}
|
||||
|
|
|
@ -33,11 +33,10 @@ hanneke ()
|
|||
foo = a; /* { dg-error "incompatible types in assignment" } */
|
||||
|
||||
/* Casted assignment between scalar and SIMD of same size. */
|
||||
foo = (typeof (foo)) foo2; /* { dg-bogus "aggregate value used where a float was expected" "" { xfail *-*-* } } */
|
||||
foo = (typeof (foo)) foo2; /* { dg-error "aggregate value used where a float was expected" } */
|
||||
|
||||
/* Casted assignment between scalar and SIMD of different size. */
|
||||
/* foo1 = (typeof (foo1)) foo2; { dg*error "can't convert between vector values of different size" } */
|
||||
foo1 = (typeof (foo1)) foo2; /* { dg-bogus "aggregate value used where a float was expected" "" { xfail *-*-* } } */
|
||||
foo1 = (typeof (foo1)) foo2; /* { dg-error "aggregate value used where a float was expected" } */
|
||||
|
||||
/* Operators on compatible SIMD types. */
|
||||
a += b + b;
|
||||
|
@ -48,8 +47,8 @@ hanneke ()
|
|||
c = -d;
|
||||
|
||||
/* Operators on incompatible SIMD types. */
|
||||
a = b + c; /* { dg-error "can't convert between vector values of different size" } */
|
||||
a = b - c; /* { dg-error "can't convert between vector values of different size" } */
|
||||
a = b * c; /* { dg-error "can't convert between vector values of different size" } */
|
||||
a = b / c; /* { dg-error "can't convert between vector values of different size" } */
|
||||
a = b + c; /* { dg-error "invalid operands to binary" } */
|
||||
a = b - c; /* { dg-error "invalid operands to binary" } */
|
||||
a = b * c; /* { dg-error "invalid operands to binary" } */
|
||||
a = b / c; /* { dg-error "invalid operands to binary" } */
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
/* { dg-do compile } */
|
||||
|
||||
typedef int myint;
|
||||
|
||||
float __attribute__((vector_size(16))) b;
|
||||
int __attribute__((vector_size(16))) d;
|
||||
myint __attribute__((vector_size(16))) d2;
|
||||
unsigned int __attribute__((vector_size(16))) e;
|
||||
|
||||
void foo()
|
||||
{
|
||||
b + d; /* { dg-error "invalid operands to binary" } */
|
||||
d += e;
|
||||
d2 += d;
|
||||
}
|
Loading…
Reference in New Issue