From 49b64e8dc717dd6db27dabd74b0fe238af5e8208 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 --- compiler/pragmas.nim | 13 +++++++------ tests/proc/tlambdapragma.nim | 7 +++++++ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 tests/proc/tlambdapragma.nim diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 50b8c338fb..8fbdd3579f 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -22,7 +22,7 @@ const const declPragmas = {wImportc, wImportObjC, wImportCpp, wImportJs, wExportc, wExportCpp, - wExportNims, wExtern, wDeprecated, wNodecl, wError, wUsed, wAlign} + wExportNims, wExtern, wDeprecated, wNodecl, wError, wUsed} ## common pragmas for declarations, to a good approximation procPragmas* = declPragmas + {FirstCallConv..LastCallConv, wMagic, wNoSideEffect, wSideEffect, wNoreturn, wNosinks, wDynlib, wHeader, @@ -56,22 +56,23 @@ const wFloatChecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, wLinearScanEnd, wPatterns, wTrMacros, wEffects, wNoForward, wReorder, wComputedGoto, wInjectStmt, wExperimental, wThis, wUsed, wInvariant, wAssume, wAssert} - lambdaPragmas* = declPragmas + {FirstCallConv..LastCallConv, + lambdaPragmas* = {FirstCallConv..LastCallConv, wNoSideEffect, wSideEffect, wNoreturn, wNosinks, wDynlib, wHeader, wThread, wAsmNoStackFrame, wRaises, wLocks, wTags, wRequires, wEnsures, - wGcSafe, wCodegenDecl} - {wExportNims, wError, wUsed} # why exclude these? + wGcSafe, wCodegenDecl, wNoInit} typePragmas* = declPragmas + {wMagic, wAcyclic, wPure, wHeader, wCompilerProc, wCore, wFinal, wSize, wShallow, wIncompleteStruct, wCompleteStruct, wByCopy, wByRef, wInheritable, wGensym, wInject, wRequiresInit, wUnchecked, wUnion, wPacked, wCppNonPod, wBorrow, wGcSafe, wPartial, wExplain, wPackage} - fieldPragmas* = declPragmas + { - wGuard, wBitsize, wCursor, wRequiresInit, wNoalias} - {wExportNims, wNodecl} # why exclude these? + fieldPragmas* = declPragmas + {wGuard, wBitsize, wCursor, + wRequiresInit, wNoalias, wAlign} - {wExportNims, wNodecl} # why exclude these? varPragmas* = declPragmas + {wVolatile, wRegister, wThreadVar, wMagic, wHeader, wCompilerProc, wCore, wDynlib, wNoInit, wCompileTime, wGlobal, - wGensym, wInject, wCodegenDecl, wGuard, wGoto, wCursor, wNoalias} + wGensym, wInject, wCodegenDecl, + wGuard, wGoto, wCursor, wNoalias, wAlign} constPragmas* = declPragmas + {wHeader, wMagic, wGensym, wInject, wIntDefine, wStrDefine, wBoolDefine, wCompilerProc, wCore} 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