Before showing deprecated warning, check whether enum field was marked deprecated or the whole enum type (#10135)

This commit is contained in:
Neelesh Chandola 2018-12-30 23:04:41 +05:30 • committed by Andreas Rumpf
commit bcbe317d17

View file

@ -464,7 +464,7 @@ proc extractPragma(s: PSym): PNode =
proc warnAboutDeprecated(conf: ConfigRef; info: TLineInfo; s: PSym) = proc warnAboutDeprecated(conf: ConfigRef; info: TLineInfo; s: PSym) =
let pragmaNode = if s.kind == skEnumField: extractPragma(s.owner) else: extractPragma(s) let pragmaNode = if s.kind == skEnumField: extractPragma(s.owner) else: extractPragma(s)
let name = let name =
if s.kind == skEnumField: "enum '" & s.owner.name.s & "' which contains field '" & s.name.s & "'" if s.kind == skEnumField and sfDeprecated notin s.flags: "enum '" & s.owner.name.s & "' which contains field '" & s.name.s & "'"
else: s.name.s else: s.name.s
if pragmaNode != nil: if pragmaNode != nil:
for it in pragmaNode: for it in pragmaNode:
@ -490,7 +490,7 @@ proc markUsed(conf: ConfigRef; info: TLineInfo; s: PSym; usageSym: var PSym) =
if s.kind == skEnumField and s.owner != nil: if s.kind == skEnumField and s.owner != nil:
incl(s.owner.flags, sfUsed) incl(s.owner.flags, sfUsed)
if sfDeprecated in s.owner.flags: if sfDeprecated in s.owner.flags:
incl(s.flags, sfDeprecated) warnAboutDeprecated(conf, info, s)
if {sfDeprecated, sfError} * s.flags != {}: if {sfDeprecated, sfError} * s.flags != {}:
if sfDeprecated in s.flags: warnAboutDeprecated(conf, info, s) if sfDeprecated in s.flags: warnAboutDeprecated(conf, info, s)
if sfError in s.flags: userError(conf, info, s) if sfError in s.flags: userError(conf, info, s)