From e749fc08e765152f2a60b6af646d19314b86c0dc Mon Sep 17 00:00:00 2001 From: cooldome Date: Fri, 5 Apr 2019 13:50:57 +0100 Subject: [PATCH] fixes #10943 (#10947) --- compiler/cgen.nim | 5 ++++- tests/constr/a_module.nim | 6 ++++++ tests/constr/tglobal.nim | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/constr/a_module.nim create mode 100644 tests/constr/tglobal.nim diff --git a/compiler/cgen.nim b/compiler/cgen.nim index da5e3603b9..223ed4dbcc 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1619,7 +1619,10 @@ proc genModule(m: BModule, cfile: Cfile): Rope = add(result, m.s[cfsHeaders]) add(result, genSectionEnd(cfsHeaders, m.config)) add(result, genSectionStart(cfsFrameDefines, m.config)) - add(result, m.s[cfsFrameDefines]) + if m.s[cfsFrameDefines].len > 0: + add(result, m.s[cfsFrameDefines]) + else: + add(result, "#define nimfr_(x, y)\n#define nimln_(x, y)\n") add(result, genSectionEnd(cfsFrameDefines, m.config)) for i in countup(cfsForwardTypes, cfsProcs): diff --git a/tests/constr/a_module.nim b/tests/constr/a_module.nim new file mode 100644 index 0000000000..1d3f4848c3 --- /dev/null +++ b/tests/constr/a_module.nim @@ -0,0 +1,6 @@ +# a.nim +{.push stackTrace: off.} +proc foo*(): int = + var a {.global.} = 0 + result = a +{.pop.} \ No newline at end of file diff --git a/tests/constr/tglobal.nim b/tests/constr/tglobal.nim new file mode 100644 index 0000000000..056ac9f81d --- /dev/null +++ b/tests/constr/tglobal.nim @@ -0,0 +1,7 @@ +discard """ +output: "0" +""" + +# b.nim +import a_module +echo foo() \ No newline at end of file