[llvm-bugs] [Bug 43667] New: Wshadow-field-in-constructor warning is not enabled by corresponding command line option

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 13 22:36:13 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43667

            Bug ID: 43667
           Summary: Wshadow-field-in-constructor warning is not enabled by
                    corresponding command line option
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm at mrks.info
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Created attachment 22668
  --> https://bugs.llvm.org/attachment.cgi?id=22668&action=edit
test case

The attached test case should produce a warning saying that the `v` constructor
argument shadows the `v` class member. With -Wshadow-all, this happens as
expected:

    <source>:5:24: error: constructor parameter 'v' shadows the field 'v' of
'S' [-Werror,-Wshadow-field-in-constructor]
        S(std::vector<int> v) : v(std::move(v)) {
                           ^

    <source>:8:22: note: previous declaration is here
        std::vector<int> v;
                         ^

However, the warning / error is described to be coming from
-Wshadow-field-in-constructor. Accordingly, I would expect that flag alone to
be sufficient to turn on the warning. However, when replacing -Wshadow-all with
that flag, no warning is emitted.

Compiler Explorer: https://godbolt.org/z/8cN1-W

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191014/97920290/attachment.html>


More information about the llvm-bugs mailing list