From bc770aac72f5d92484ebf989c0a9a5c2877e408b Mon Sep 17 00:00:00 2001 From: Hiroki Noda Date: Tue, 10 Mar 2020 08:08:19 +0900 Subject: [PATCH] Fix Issue 20656 - cannot compile live function without -preview=dip1021 --- src/dmd/semantic3.d | 3 ++- test/compilable/test20656.d | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/compilable/test20656.d diff --git a/src/dmd/semantic3.d b/src/dmd/semantic3.d index 1a287d4eb42c..3bd55861b6d1 100644 --- a/src/dmd/semantic3.d +++ b/src/dmd/semantic3.d @@ -1336,7 +1336,8 @@ private extern(C++) final class Semantic3Visitor : Visitor } // Do live analysis - if (funcdecl.fbody && funcdecl.type.ty != Terror && funcdecl.type.isTypeFunction().islive) + if (global.params.useDIP1021 && funcdecl.fbody && funcdecl.type.ty != Terror && + funcdecl.type.isTypeFunction().islive) { oblive(funcdecl); } diff --git a/test/compilable/test20656.d b/test/compilable/test20656.d new file mode 100644 index 000000000000..f68d65470263 --- /dev/null +++ b/test/compilable/test20656.d @@ -0,0 +1,11 @@ +// https://issues.dlang.org/show_bug.cgi?id=20656 + +import core.stdc.stdlib : free, malloc; + +@live +void main() +{ + auto p = malloc(1); + free(p); + free(p); +}