This fixes a common mistake (the 3 should be @3): NSNumber *n = 3. This extends an existing check for NSString. Also, this only errs if the initializer isn't a null pointer constant, so NSNumber *n = 0; continues to work.
Fixes rdar://47029572
Paths
| Differential D78066
[SemaObjC] Forbid storing an unboxed integer literal in an NSNumber ClosedPublic Authored by erik.pilkington on Apr 13 2020, 5:01 PM.
Details Summary This fixes a common mistake (the 3 should be @3): NSNumber *n = 3. This extends an existing check for NSString. Also, this only errs if the initializer isn't a null pointer constant, so NSNumber *n = 0; continues to work. Fixes rdar://47029572
Diff Detail
Event TimelineHerald added subscribers: ributzka, dexonsmith, jkorous. · View Herald TranscriptApr 13 2020, 5:01 PM This revision is now accepted and ready to land.Apr 13 2020, 5:31 PM Closed by commit rG85cca945b4c9: [SemaObjC] Forbid storing an unboxed integer literal in an NSNumber (authored by erik.pilkington). · Explain WhyApr 20 2020, 12:28 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 258814 clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprObjC.cpp
clang/lib/Sema/SemaInit.cpp
clang/test/SemaObjC/objc-literal-fixit.m
|