<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 11, 2011, at 3:02 PM, Nikola Smiljanic wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><div class="gmail_quote">On Thu, Aug 11, 2011 at 7:07 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div style="word-wrap:break-word"><div><br></div><div>This doesn't look right… it looks like it'll allow *all* notes to be printed, even if the warning/error preceding that note was suppressed. What we really want is for the notes corresponding to the last displayed error to be displayed, but subsequent notes should still be suppressed.</div>

<div><br></div><div><span style="white-space:pre-wrap"> </span>- Doug</div></div></blockquote></div><br><div><br></div><div>You're right. It seems that this logic is already in place but it doesn't work and here's why: The error is emitted and delayed diagnostic is set (fatal error). So when ReportDelayed() is called it emits the fatal error but it still has delayed diagnostic set (itself) which causes another ReportDelayed to be called, and this one defeats the logic.</div>

<div><br></div><div>The fix would be to reset DelayedDiagID before reporting it, like this:</div><div><br></div><div>// store the object returned by Report in order to make its destructor run after DelayedDiagID is set to zero</div>

<div><div>void Diagnostic::ReportDelayed() {</div><div>  DiagnosticBuilder diagBuilder = Report(DelayedDiagID);</div><div>  diagBuilder << DelayedDiagArg1 << DelayedDiagArg2;</div><div>  DelayedDiagID = 0;</div>

<div>}</div></div><div><br></div><div>// reset DelayedDiagID before calling Report, but create the temporary to save the value</div><div><div>void Diagnostic::ReportDelayed() {</div><div>  int temp = DelayedDiagID;</div>
<div>
  DelayedDiagID = 0;</div><div>  Report(temp) << DelayedDiagArg1 << DelayedDiagArg2;</div><div>}</div></div><div><br></div><div>// pass DelayedDiagID as the argument (this is passing its own member as an argument)</div>

<div><div>void Diagnostic::ReportDelayed(int id) {</div><div>  DelayedDiagID = 0;</div><div>  Report(id) << DelayedDiagArg1 << DelayedDiagArg2;</div><div>}</div></div><div><br></div><div>The first one is the most reasonable one for me. What do you think?</div>

</blockquote></div><br><div>The first one seems reasonable. Can you update your patch with this fix + test cases?</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div></body></html>