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
This commit is contained in:
Jakub Jelinek 2006-11-21 10:41:27 +01:00 committed by Jakub Jelinek
parent b509487e88
commit 4576ceaf22
6 changed files with 86 additions and 3 deletions

View File

@ -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

View File

@ -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. */

View File

@ -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;
}

View File

@ -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)))

View File

@ -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

View File

@ -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" }
}