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

             Bug #: 13474
           Summary: Feature request: warning for unnecessary __block
                    keywords
           Product: clang
           Version: 3.1
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


Since clang can detect variables that need to be annotated with the __block
keyword but are not, I was hoping the converse might be possible.

Specifically, consider:

#include <stdio.h>

int main(int argc, char **argv) {
    __block int i;
    for (i = 0; i < argc; i++) {
        printf("argv[%d] is %s\n", i, argv[i]);
    }
    return 0;
}

Clang will happily compile this with -Wall -Wextra without a peep and will
generate code that allows 'i' to be used from a block (set-up extra state on
the stack and call Block_object_dispose()). Since there is a performance cost
in the emitted code, it would be nice if the compile could detect when __block
variables are not referenced from within a block and warn about it. Or,
alternatively, just optimize away the code for handling the block-ness. 

I am using:
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to