diff --git a/tests/plugins/lit.local.cfg b/tests/plugins/lit.local.cfg index 9b1ae7fa6ff..a856482ce54 100644 --- a/tests/plugins/lit.local.cfg +++ b/tests/plugins/lit.local.cfg @@ -11,6 +11,7 @@ if (config.plugins_supported): '--d-version=IN_LLVM', '-J' + config.ldc2_source_dir + '/dmd/res', '--shared', + '--defaultlib=', ] if (platform.system() == 'Darwin'): plugin_compile_flags.append('-L-Wl,-undefined,dynamic_lookup') diff --git a/tests/plugins/visitor_example.d b/tests/plugins/visitor_example.d new file mode 100644 index 00000000000..0754e0c37d9 --- /dev/null +++ b/tests/plugins/visitor_example.d @@ -0,0 +1,51 @@ +// REQUIRES: Plugins + +// RUN: split-file %s %t --leading-lines +// RUN: %ldc -g %t/plugin.d %plugin_compile_flags -of=%t/plugin%so +// RUN: %ldc -wi -c -o- --plugin=%t/plugin%so %t/testcase.d 2>&1 | FileCheck %t/testcase.d + +//--- plugin.d +import dmd.dmodule; +import dmd.errors; +import dmd.location; +import dmd.visitor; +import dmd.declaration; +import dmd.dsymbol; + +extern(C++) class MyVisitor : SemanticTimeTransitiveVisitor { + alias visit = SemanticTimeTransitiveVisitor.visit; + + override void visit(VarDeclaration vd) { + if (vd.aliasTuple) + warning(vd.loc, "It works!"); + } +} + +extern(C) void runSemanticAnalysis(Module m) { + scope v = new MyVisitor(); + if (!m.members) + return; + m.members.foreachDsymbol((s) { + s.accept(v); + }); +} + +//--- testcase.d +alias AliasSeq(TList...) = TList; + +int i = 0; +struct A { + ~this() { + i *= 2; + } +} + +void main() { + { + // CHECK: testcase.d([[@LINE+1]]): Warning: + AliasSeq!(A, A) params; + i = 1; + } + + assert(i == 4); +}