[LLVMbugs] [Bug 10275] New: format function attribute isn't checked in Objective-C methods

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 4 23:15:28 PDT 2011


           Summary: format function attribute isn't checked in Objective-C
           Product: clang
           Version: 2.9
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: macbavarious at gmail.com
                CC: llvmbugs at cs.uiuc.edu

The following code:

#import <Foundation/NSString.h>

@interface Test
+ (void)test2:(NSString *)format, ... __attribute__((format(__NSString__, 1,
+ (void)test3:(const char *)format, ... __attribute__((format(__printf__, 1,
- (void)test4:(NSString *)format, ... __attribute__((format(__NSString__, 1,
- (void)test5:(const char *)format, ... __attribute__((format(__printf__, 1,

void function(void) {
    [Test test2:@"%d"];
    [Test test2:@"%d", "foo"];

    [Test test3:"%d"];
    [Test test3:"%d", "foo"];

    Test *t;
    [t test4:@"%d"];
    [t test4:@"%d", "foo"];

    [t test5:"%d"];
    [t test5:"%d", "foo"];

which uses both the __printf__ and the __NSString__ archetypes in the format
function attribute, doesn't yield any compiler warnings even though there's a
mismatch in the number of arguments and the argument types:

$ clang -c -Wformat bug1.m

This has been tested with:

$ clang --version
Apple clang version 2.0 (tags/Apple/clang-137) (based on LLVM 2.9svn)
Target: x86_64-apple-darwin10
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.

More information about the llvm-bugs mailing list