Reland "Thread Safety Analysis: fix assert_capability."
Delete the test that was broken by rL309725, and add it back in a
follow up commit. Also, improve the tests a bit.
Thread Safety Analysis: warn on nonsensical attributes.
Add warnings in cases where an implicit this argument is expected to
attributes because either this doesn't exist because the attribute is
on a free function, or because this is on a type that doesn't have a
corresponding capability/lockable/scoped_lockable attribute.