On Fri, Jan 5, 2018 at 5:14 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> Jason's recent change removed a mark_rvalue_use call from constant_value_1,
> which unfortunately regressed quite a few cases where
> -Wunused-but-set-variable now has false positives.

> The easiest fix seems to be just deal with the -Wunused-but-set-variable
> issue at that point.

Hmm, we ought to have called mark_rvalue_use before we get here.  I'm
concerned that these issues indicate that lambda captures won't work
in the situations in the testcase, since we rely on mark_rvalue_use to
look through them.

[checks]

And indeed the first testcase breaks if the switch is wrapped in a
lambda that can capture i.

void
foo ()
{
  const int i = 1;             // { dg-bogus "set but not used" }

  [=]()
    {
      switch (0)
        {
        case i:
          break;
        }
    };
}

Jason

Reply via email to