1\version "2.19.80"
2
3\header {
4  texidoc = "A @code{\\denies} statement in a @code{\\with} block
5applies to the local context only; it does not change the global
6context definition.  The lower staff should hold a B-sharp."
7}
8
9\layout {
10  \context {
11    \Staff
12    \remove "Accidental_engraver"
13    \accepts "AdHocPaddingOne"
14    \accepts "AdHocVoice" % important: this is not first in the accepts list
15    \accepts "AdHocPaddingTwo"
16  }
17
18  \context {
19    \Voice
20    \name "AdHocVoice"
21    \alias Voice
22    \consists "Accidental_engraver"
23  }
24}
25
26\new Score <<
27  \new Staff \with { \denies "AdHocVoice" } <<
28    R1
29  >>
30  \new Staff <<
31    %% If the \denies in the upper staff were wrongly carried over to
32    %% this one, LilyPond would refuse to create an AdHocVoice and no
33    %% accidental would be engraved.
34    \new AdHocVoice bis'1
35  >>
36>>
37