[LLVMbugs] [Bug 15859] New: Variables named `_` should not trigger -Wunused-parameter

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Apr 27 17:25:00 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=15859

            Bug ID: 15859
           Summary: Variables named `_` should not trigger
                    -Wunused-parameter
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kenneth at ballenegger.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

It is common convention in other programming languages to use the variable name
`_` for unused parameters. In C, with blocks for callbacks, and in Objective-C
when using the delegation pattern, there are many valid use cases in which one
would not use a parameter (eg. when your block type / method signature is
defined in a third party api).

I think it would be best not to trigger the `unused-parameter` warning for
variables named `_`. That would enable users of the API to specify their
intention to actually not use the variable.

For example:

    - (IBAction)someAction:(id)_ { // <- warning, unused parameter
        printf("Hello, world!\n");
    }

Or:

    // In an API:
    void calculate_something(MyBlock callback);
    typedef void(^MyBlock)(int, char *info_message);

    // In end-developer code:
    {
        calculate_something(^(int i, char *_) { // <- warning
            printf("Int is: %d\n", i);
        });
    }

-- 
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/20130428/eac5bebd/attachment.html>


More information about the llvm-bugs mailing list