diff --git a/tests/plugins/lit.local.cfg b/tests/plugins/lit.local.cfg index a856482ce54..4d4c70576e8 100644 --- a/tests/plugins/lit.local.cfg +++ b/tests/plugins/lit.local.cfg @@ -1,6 +1,12 @@ +import lit.formats +import lit.util import os +import sys import platform +import string import re +import subprocess +import glob if (config.plugins_supported): config.available_features.add('Plugins') @@ -17,4 +23,18 @@ if (config.plugins_supported): plugin_compile_flags.append('-L-Wl,-undefined,dynamic_lookup') config.substitutions.append( ('%plugin_compile_flags', " ".join(plugin_compile_flags) ) ) + # Set feature that tells us that the just-built LDC is ABI compatible with the host D compiler + # Be conservative: only set it when host LDC and just-built LDC have identical versions + command = [config.ldc2_bin, '--version'] + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) + text1 = p.stdout.readline() # Ex.: "LDC - the LLVM D compiler (1.33.0-git-716f627)" + text2 = p.stdout.readline() # Ex.: " based on DMD v2.103.1 and LLVM 14.0.0" + text3 = p.stdout.readline() # Ex.: " built with LDC - the LLVM D compiler (1.33.0-beta2)" + m = re.compile('LDC - the LLVM D compiler \((.*)\)').match(text1) + ldc_version = m.group(1) + m3 = re.compile(' built with.* \((.*)\)').match(text3) + host_version = m3.group(1) + if (ldc_version == host_version): + config.available_features.add('ABI_compatible_with_host_D') + diff --git a/tests/plugins/visitor_example.d b/tests/plugins/visitor_example.d index 0754e0c37d9..e96ed0252f1 100644 --- a/tests/plugins/visitor_example.d +++ b/tests/plugins/visitor_example.d @@ -1,4 +1,5 @@ // REQUIRES: Plugins +// REQUIRES: ABI_compatible_with_host_D // RUN: split-file %s %t --leading-lines // RUN: %ldc -g %t/plugin.d %plugin_compile_flags -of=%t/plugin%so @@ -16,8 +17,14 @@ extern(C++) class MyVisitor : SemanticTimeTransitiveVisitor { alias visit = SemanticTimeTransitiveVisitor.visit; override void visit(VarDeclaration vd) { - if (vd.aliasTuple) - warning(vd.loc, "It works!"); + if (vd.aliasTuple) { + vd.aliasTuple.foreachVar((s) { + auto vardecl = s.isVarDeclaration(); + if (vardecl && vardecl.type.needsDestruction()) { + warning(vardecl.loc, "It works!"); + } + }); + } } }