Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gen/semantic-dcompute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ struct DComputeSemanticAnalyser : public StoppableVisitor {
return;
}

if (!decl->type)
return;

if (decl->type->ty == TY::Taarray) {
error(decl->loc, "associative arrays not allowed in `@compute` code");
stop = true;
Expand Down
14 changes: 14 additions & 0 deletions tests/compilable/dcompute_template_import.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Regression test: importing a module with a recursive template via -I and using
// __traits(compiles, ...) on it should not crash the compiler during dcompute
// semantic analysis. Previously, the VarDeclaration's type field could be null
// for error'd template instantiations, causing a segfault in
// DComputeSemanticAnalyser::visit(VarDeclaration*).

// REQUIRES: target_NVPTX
// RUN: %ldc -mdcompute-targets=cuda-350 -o- -I%S/inputs %s

@compute(CompileFor.deviceOnly) module tests.compilable.dcompute_template_import;
import ldc.dcompute;
import dcompute_testmod;

static assert(!__traits(compiles, { imported!"dcompute_testmod".hasIndirections!(int[]); }));
5 changes: 5 additions & 0 deletions tests/compilable/inputs/dcompute_testmod.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
template hasIndirections(T)
{
static if (is(T == enum))
enum hasIndirections = hasIndirections;
}
Loading