From 286b94e7dee4e4a6ba5c9b8a0c078edc4d12b3fe Mon Sep 17 00:00:00 2001 From: hlaaftana <10591326+hlaaftana@users.noreply.github.com> Date: Tue, 9 Feb 2021 16:23:06 +0300 Subject: [PATCH] Remove declPragmas from lambdas [backport:1.0] (#16966) * Remove declPragmas from lambdas [backport:1.0] * add test for exportc * fix test * fix align, nodecl -> noinit (cherry picked from commit 49b64e8dc717dd6db27dabd74b0fe238af5e8208) --- compiler/pragmas.nim | 6 +++--- tests/proc/tlambdapragma.nim | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tests/proc/tlambdapragma.nim diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index fdc1619a35..3caa7b702f 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -52,17 +52,17 @@ const wFloatChecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, wLinearScanEnd, wPatterns, wTrMacros, wEffects, wNoForward, wReorder, wComputedGoto, wInjectStmt, wExperimental, wThis, wUsed} - lambdaPragmas* = declPragmas + {FirstCallConv..LastCallConv, + lambdaPragmas* = {FirstCallConv..LastCallConv, wNoSideEffect, wSideEffect, wNoreturn, wDynlib, wHeader, wThread, wAsmNoStackFrame, - wRaises, wLocks, wTags, wGcSafe, wCodegenDecl} - {wExportNims, wError, wUsed} # why exclude these? + wRaises, wLocks, wTags, wGcSafe, wCodegenDecl, wNoInit} typePragmas* = declPragmas + {wMagic, wAcyclic, wPure, wHeader, wCompilerProc, wCore, wFinal, wSize, wShallow, wIncompleteStruct, wByCopy, wByRef, wInheritable, wGensym, wInject, wRequiresInit, wUnchecked, wUnion, wPacked, wBorrow, wGcSafe, wPartial, wExplain, wPackage} fieldPragmas* = declPragmas + { - wGuard, wBitsize} - {wExportNims, wNodecl} # why exclude these? + wGuard, wBitsize, wAlign} - {wExportNims, wNodecl} # why exclude these? varPragmas* = declPragmas + {wVolatile, wRegister, wThreadVar, wMagic, wHeader, wCompilerProc, wCore, wDynlib, wNoInit, wCompileTime, wGlobal, diff --git a/tests/proc/tlambdapragma.nim b/tests/proc/tlambdapragma.nim new file mode 100644 index 0000000000..daa952b1ef --- /dev/null +++ b/tests/proc/tlambdapragma.nim @@ -0,0 +1,7 @@ +discard """ + errormsg: "invalid pragma: exportc" +""" + +let _ = proc () {.exportc.} = + # this would previously cause a codegen error + discard