Skip to content

regression: clang -Wunused-parameter stopped warning for unused params in Objective-C methods at some point #117931

Open
@seanm

Description

@seanm

I don't know when it happened, and godbolt compiler explorer does not support Obj-C with clang, but clang's -Wunused-parameter used to warn for unused Obj-C method parameters, but now it doesn't.

Example code:

@interface RRPoint

- (instancetype)initWithX:(double)inX Y:(double)inY Z:(double)inZ;

@end

@implementation RRPoint

- (instancetype)initWithX:(double)inX Y:(double)inY Z:(double)inZ
{
	return self;
}

@end

int main (int argc, const char * argv[])
{
	return 0;
}

Result with old AppleClang 10 (Xcode 10.1):

builder22:Desktop builder$ xcrun clang --version
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
builder22:Desktop builder$ xcrun clang -fsyntax-only -Wunused-parameter test.m
test.m:9:35: warning: unused parameter 'inX' [-Wunused-parameter]
- (instancetype)initWithX:(double)inX Y:(double)inY Z:(double)inZ
                                  ^

Yet with newer AppleClang and open source clang 19.1.3, there is no warning.

(Godbolt compiler explorer does support Obj-C with gcc, and gcc does still warn here, FWIW)

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerobjective-cregression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions