diff options
author | Jakub Jelinek <jakub@redhat.com> | 2006-11-21 10:41:27 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2006-11-21 10:41:27 +0100 |
commit | 4576ceaf227bb48e2771f388405e3043b5e4ffeb (patch) | |
tree | dfda9b44bba52234a55d6932d2b7e09d01cdb2bb /gcc | |
parent | b509487e8855a198e2fd7b40316b6d124ef3afc4 (diff) | |
download | gcc-4576ceaf227bb48e2771f388405e3043b5e4ffeb.zip gcc-4576ceaf227bb48e2771f388405e3043b5e4ffeb.tar.gz gcc-4576ceaf227bb48e2771f388405e3043b5e4ffeb.tar.bz2 |
re PR c++/29734 (ICE with vector in switch condition)
PR c++/29734
* cp-tree.h (WANT_VECTOR): Define.
(WANT_ARITH): Add WANT_VECTOR.
* cvt.c (build_expr_type_conversion): Handle vector types.
* typeck.c (build_unary_op): Add WANT_VECTOR to
build_expr_type_conversion flags.
* g++.dg/conversion/simd4.C: New test.
From-SVN: r119044
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 3 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 35 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/conversion/simd4.C | 34 |
6 files changed, 86 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5d0dd5c..295ed76 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2006-11-21 Jakub Jelinek <jakub@redhat.com> + + PR c++/29734 + * cp-tree.h (WANT_VECTOR): Define. + (WANT_ARITH): Add WANT_VECTOR. + * cvt.c (build_expr_type_conversion): Handle vector types. + * typeck.c (build_unary_op): Add WANT_VECTOR to + build_expr_type_conversion flags. + 2006-11-20 Simon Martin <simartin@users.sourceforge.net> PR c++/29475 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index d7e523b..43e6e29 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3468,7 +3468,8 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG }; #define WANT_ENUM 4 /* enumerated types */ #define WANT_POINTER 8 /* pointer types */ #define WANT_NULL 16 /* null pointer constant */ -#define WANT_ARITH (WANT_INT | WANT_FLOAT) +#define WANT_VECTOR 32 /* vector types */ +#define WANT_ARITH (WANT_INT | WANT_FLOAT | WANT_VECTOR) /* Used with comptypes, and related functions, to guide type comparison. */ diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 6f61218..f09f708 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1103,7 +1103,6 @@ build_expr_type_conversion (int desires, tree expr, bool complain) return expr; /* else fall through... */ - case VECTOR_TYPE: case BOOLEAN_TYPE: return (desires & WANT_INT) ? expr : NULL_TREE; case ENUMERAL_TYPE: @@ -1117,6 +1116,23 @@ build_expr_type_conversion (int desires, tree expr, bool complain) case ARRAY_TYPE: return (desires & WANT_POINTER) ? decay_conversion (expr) : NULL_TREE; + + case VECTOR_TYPE: + if ((desires & WANT_VECTOR) == 0) + return NULL_TREE; + switch (TREE_CODE (TREE_TYPE (basetype))) + { + case INTEGER_TYPE: + case BOOLEAN_TYPE: + return (desires & WANT_INT) ? expr : NULL_TREE; + case ENUMERAL_TYPE: + return (desires & WANT_ENUM) ? expr : NULL_TREE; + case REAL_TYPE: + return (desires & WANT_FLOAT) ? expr : NULL_TREE; + default: + return NULL_TREE; + } + default: return NULL_TREE; } @@ -1151,6 +1167,23 @@ build_expr_type_conversion (int desires, tree expr, bool complain) case POINTER_TYPE: win = (desires & WANT_POINTER); break; + case VECTOR_TYPE: + if ((desires & WANT_VECTOR) == 0) + break; + switch (TREE_CODE (TREE_TYPE (candidate))) + { + case BOOLEAN_TYPE: + case INTEGER_TYPE: + win = (desires & WANT_INT); break; + case ENUMERAL_TYPE: + win = (desires & WANT_ENUM); break; + case REAL_TYPE: + win = (desires & WANT_FLOAT); break; + default: + break; + } + break; + default: break; } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index c257f00..4146bf0 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3995,7 +3995,8 @@ build_unary_op (enum tree_code code, tree xarg, int noconvert) if (!noconvert) arg = default_conversion (arg); } - else if (!(arg = build_expr_type_conversion (WANT_INT | WANT_ENUM, + else if (!(arg = build_expr_type_conversion (WANT_INT | WANT_ENUM + | WANT_VECTOR, arg, true))) errstring = "wrong type argument to bit-complement"; else if (!noconvert && CP_INTEGRAL_TYPE_P (TREE_TYPE (arg))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3393c8e..99e57c7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-11-21 Jakub Jelinek <jakub@redhat.com> + + PR c++/29734 + * g++.dg/conversion/simd4.C: New test. + 2006-11-20 Simon Martin <simartin@users.sourceforge.net> PR c++/29475 diff --git a/gcc/testsuite/g++.dg/conversion/simd4.C b/gcc/testsuite/g++.dg/conversion/simd4.C new file mode 100644 index 0000000..f8f7f2e --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/simd4.C @@ -0,0 +1,34 @@ +// PR c++/29734 +// { dg-do compile } +// { dg-options "" } + +int t; +float u; +int __attribute__((vector_size (8))) v; +float __attribute__((vector_size (8))) w; +int b[10]; + +void +foo () +{ + b[t]; + b[u]; // { dg-error "invalid types" } + b[v]; // { dg-error "invalid types" } + b[w]; // { dg-error "invalid types" } + t[b]; + u[b]; // { dg-error "invalid types" } + v[b]; // { dg-error "invalid types" } + w[b]; // { dg-error "invalid types" } + new int[t]; + new int[u]; // { dg-error "new-declarator must have integral" } + new int[v]; // { dg-error "new-declarator must have integral" } + new int[w]; // { dg-error "new-declarator must have integral" } + switch (t) { default: break; } + switch (u) { default: break; } // { dg-error "switch quantity not an integer" } + switch (v) { default: break; } // { dg-error "switch quantity not an integer" } + switch (w) { default: break; } // { dg-error "switch quantity not an integer" } + t = ~t; + u = ~u; // { dg-error "wrong type argument to bit-complement" } + v = ~v; + w = ~w; // { dg-error "wrong type argument to bit-complement" } +} |