[PATCH] Warning on unused results in an unevaluated context

Aaron Ballman aaron at aaronballman.com
Thu Oct 16 07:23:00 PDT 2014


On Thu, Oct 16, 2014 at 9:05 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
> On Wed, Oct 15, 2014 at 10:33 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>> Does this still warn on cases like:
>>
>>   typeid(f(), g());
>>
>> where we don't know we've got an evaluated operand until after we've
>> finished parsing it?
>>
>> ... Hmm, we don't seem to get any warning on that case right now. =( Might
>> be worth someone looking into that, maybe there are other cases we're
>> missing.

I'd like to make sure my understanding is correct. Given:

#include <typeinfo>

struct B {
  virtual int f();
};

struct D : B {
  virtual int f();
};

B *h() __attribute__((warn_unused_result));
B *h() { return new D; }

int f() __attribute__((warn_unused_result));
int g();

int main() {
  const auto &t1 = typeid(f(), g()); // Should not warn; unevaluated context?
  const auto &t2 = typeid(h(), g()); // Should warn; evaluated context?
}

Is that the test case we're looking at for the typeid portion of this?

Thanks!

~Aaron



More information about the cfe-commits mailing list