Skip to content

Commit

Permalink
[Dcompute] don't crash on VarDelarations with no type
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator committed Sep 27, 2023
1 parent 5a15884 commit de345b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gen/semantic-dcompute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ struct DComputeSemanticAnalyser : public StoppableVisitor {
return;
}

if (decl->type->ty == TY::Taarray) {
if (!decl->type) {
stop = true;
return;
}
else if (decl->type->ty == TY::Taarray) {
decl->error("associative arrays not allowed in `@compute` code");
stop = true;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/semantic/dcompute_enum.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %ldc -o- -mdcompute-targets=cuda-430 %s

@compute(CompileFor.deviceOnly) module dcompute_enum;
pragma(LDC_no_moduleinfo);
import ldc.dcompute;
template isUnsigned(T)
{
static if (!__traits(isUnsigned, T))
enum isUnsigned = false;
else static if (is(T U == enum))
enum isUnsigned = isUnsigned!U;
else
enum isUnsigned = __traits(isZeroInit, T) // Not char, wchar, or dchar.
&& !is(immutable T == immutable bool) && !is(T == __vector);
}
@kernel void tst (uint* dst)
{
dst[0] = isUnsigned!(typeof(dst[0]));
}

0 comments on commit de345b6

Please sign in to comment.