Skip to content

Commit

Permalink
Fix issue 16697 - Accept __vector as type specialization in is()
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonBoy committed Jan 19, 2017
1 parent ece1cf5 commit f298a8c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/expression.d
Expand Up @@ -7646,6 +7646,12 @@ extern (C++) final class IsExp : Expression
// not valid for a parameter
break;

case TOKvector:
if (targ.ty != Tvector)
goto Lno;
tded = (cast(TypeVector)targ).basetype;
break;

default:
assert(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/parse.d
Expand Up @@ -7409,7 +7409,7 @@ final class Parser : Lexer
{
tok = token.value;
nextToken();
if (tok == TOKequal && (token.value == TOKstruct || token.value == TOKunion || token.value == TOKclass || token.value == TOKsuper || token.value == TOKenum || token.value == TOKinterface || token.value == TOKargTypes || token.value == TOKparameters || token.value == TOKconst && peek(&token).value == TOKrparen || token.value == TOKimmutable && peek(&token).value == TOKrparen || token.value == TOKshared && peek(&token).value == TOKrparen || token.value == TOKwild && peek(&token).value == TOKrparen || token.value == TOKfunction || token.value == TOKdelegate || token.value == TOKreturn))
if (tok == TOKequal && (token.value == TOKstruct || token.value == TOKunion || token.value == TOKclass || token.value == TOKsuper || token.value == TOKenum || token.value == TOKinterface || token.value == TOKargTypes || token.value == TOKparameters || token.value == TOKconst && peek(&token).value == TOKrparen || token.value == TOKimmutable && peek(&token).value == TOKrparen || token.value == TOKshared && peek(&token).value == TOKrparen || token.value == TOKwild && peek(&token).value == TOKrparen || token.value == TOKfunction || token.value == TOKdelegate || token.value == TOKreturn || (token.value == TOKvector && peek(&token).value == TOKrparen)))
{
tok2 = token.value;
nextToken();
Expand Down
13 changes: 13 additions & 0 deletions test/compilable/b16697.d
@@ -0,0 +1,13 @@
version(D_SIMD)
{
static assert(!is( float == __vector));
static assert(!is( float[1] == __vector));
static assert(!is( float[4] == __vector));
static assert( is(__vector(float[4]) == __vector));
static assert(!is(__vector(float[3]) == __vector));
static assert(!is(__vector(float[5]) == __vector));
static assert( is(__vector(float[4]) X == __vector) &&
is(X == float[4]));
static assert( is(__vector(byte[16]) X == __vector) &&
is(X == byte[16]));
}

0 comments on commit f298a8c

Please sign in to comment.