[PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 7 12:59:49 PDT 2016


rnk added a comment.

We had a conversation about this change around the office the other week, and people were concerned about false negatives like the trim_in_place one. Basically, I don't have time to discover all the ways you can modify your parameters:

  struct B {
    A a;
    B(A a) : a(a) { // modifies parameter, not member
      a.a = 42;
      modify_in_place(&a);
      a.setMember(3);
    }
  };

These kinds of bugs are uncommon, but the existing -Wshadow protects users against this today. I think it'll be OK if we give these users an extra -Wshadow-constructor preserves the more strict behavior.


http://reviews.llvm.org/D18271





More information about the cfe-commits mailing list