From a864eaafb747db0933cd1ced661d00e3d42056ec Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Wed, 20 Jun 2018 12:08:39 +0200 Subject: [PATCH] fix #666 - False positive for "trust too much" --- src/dscanner/analysis/trust_too_much.d | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/dscanner/analysis/trust_too_much.d b/src/dscanner/analysis/trust_too_much.d index 8d7d826..ee3850b 100644 --- a/src/dscanner/analysis/trust_too_much.d +++ b/src/dscanner/analysis/trust_too_much.d @@ -57,7 +57,11 @@ public: override void visit(const Declaration d) { const oldCheckAtAttribute = checkAtAttribute; - checkAtAttribute = d.functionDeclaration is null; + + checkAtAttribute = d.functionDeclaration is null && d.unittest_ is null && + d.constructor is null && d.destructor is null && + d.staticConstructor is null && d.staticDestructor is null && + d.sharedStaticConstructor is null && d.sharedStaticDestructor is null; d.accept(this); checkAtAttribute = oldCheckAtAttribute; } @@ -145,5 +149,10 @@ unittest alias nothrow @trusted uint F4(); }c , sac); + assertAnalyzerWarnings(q{ + @trusted ~this(); + @trusted this(); + }c , sac); + stderr.writeln("Unittest for TrustTooMuchCheck passed."); }