bugfix: 'error' statement pragma works as expected again

This commit is contained in:
Araq 2012-04-16 17:23:44 +02:00
commit d4c2f2509c
2 changed files with 11 additions and 8 deletions

View file

@ -26,7 +26,7 @@ const
wNoStackFrame, wError, wDiscardable, wNoInit} wNoStackFrame, wError, wDiscardable, wNoInit}
converterPragmas* = procPragmas converterPragmas* = procPragmas
methodPragmas* = procPragmas methodPragmas* = procPragmas
templatePragmas* = {wImmediate} templatePragmas* = {wImmediate, wDeprecated, wError}
macroPragmas* = {FirstCallConv..LastCallConv, wImmediate, wImportc, wExportc, macroPragmas* = {FirstCallConv..LastCallConv, wImmediate, wImportc, wExportc,
wNodecl, wMagic, wNosideEffect, wCompilerProc, wDeprecated, wExtern, wNodecl, wMagic, wNosideEffect, wCompilerProc, wDeprecated, wExtern,
wImportcpp, wImportobjc, wError, wDiscardable} wImportcpp, wImportobjc, wError, wDiscardable}
@ -560,7 +560,11 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
of wHint: Message(it.info, hintUser, expectStrLit(c, it)) of wHint: Message(it.info, hintUser, expectStrLit(c, it))
of wWarning: Message(it.info, warnUser, expectStrLit(c, it)) of wWarning: Message(it.info, warnUser, expectStrLit(c, it))
of wError: of wError:
if sym != nil: if sym != nil and sym.isRoutine:
# This is subtle but correct: the error *statement* is only
# allowed for top level statements. Seems to be easier than
# distinguishing properly between
# ``proc p() {.error}`` and ``proc p() = {.error: "msg".}``
noVal(it) noVal(it)
incl(sym.flags, sfError) incl(sym.flags, sfError)
else: else:
@ -609,12 +613,12 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) =
else: invalidPragma(it) else: invalidPragma(it)
else: invalidPragma(it) else: invalidPragma(it)
else: processNote(c, it) else: processNote(c, it)
if (sym != nil) and (sym.kind != skModule): if sym != nil and sym.kind != skModule:
if (lfExportLib in sym.loc.flags) and not (sfExportc in sym.flags): if lfExportLib in sym.loc.flags and sfExportc notin sym.flags:
LocalError(n.info, errDynlibRequiresExportc) LocalError(n.info, errDynlibRequiresExportc)
var lib = POptionEntry(c.optionstack.tail).dynlib var lib = POptionEntry(c.optionstack.tail).dynlib
if ({lfDynamicLib, lfHeader} * sym.loc.flags == {}) and if {lfDynamicLib, lfHeader} * sym.loc.flags == {} and
(sfImportc in sym.flags) and (lib != nil): sfImportc in sym.flags and lib != nil:
incl(sym.loc.flags, lfDynamicLib) incl(sym.loc.flags, lfDynamicLib)
addToLib(lib, sym) addToLib(lib, sym)
if sym.loc.r == nil: sym.loc.r = toRope(sym.name.s) if sym.loc.r == nil: sym.loc.r = toRope(sym.name.s)

View file

@ -44,7 +44,6 @@ Bugs
- bug: stress testing basic method example (eval example) - bug: stress testing basic method example (eval example)
without ``-d:release`` leaks memory? without ``-d:release`` leaks memory?
- bug: object {.pure, final.} does not work again! - bug: object {.pure, final.} does not work again!
- bug: {.error: "msg".} produces invalid pragma message
- bug: pragma statements in combination with symbol files are evaluated twice - bug: pragma statements in combination with symbol files are evaluated twice
but this can lead to compilation errors but this can lead to compilation errors