https://llvm.org/bugs/show_bug.cgi?id=27192

            Bug ID: 27192
           Summary: ?: operator does not remove nullable
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangb...@nondot.org
          Reporter: pe...@stairways.com.au
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

The code:

#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wnullable-to-nonnull-conversion"

void Test()
{
    NSDictionary* d = @{};
    CGPoint location = NSPointFromString( d[@"Nothing"] ?: @"{0,0}" );
    NSLog( @"location is %@", NSStringFromPoint(location) );
}

#pragma clang diagnostic pop

Reports the warning:

>warning: implicit conversion from nullable pointer 'id _Nullable' to 
>non-nullable pointer type 'NSString * _Nonnull' 
>[-Wnullable-to-nonnull-conversion]
>        CGPoint location = NSPointFromString( d[@"Nothing"] ?: @"{0,0}" );

The ?: operator should be smart enough to know that if the right hand is
non-nullable then the entire expression is non-nullable.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to