__auto_type does not infer nullability annotation

Originator:kevin
Number:rdar://36877120 Date Originated:January 25 2018, 11:50 AM
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification:Other Bug Reproducible:Always
 
Summary:
Using __auto_type in Obj-C does not infer the nullability annotation. 

1. It doesn't propagate any nullability annotations from the initializer expression, and
2. If you add an explicit nullability annotation it ignores it.

Steps to Reproduce:
Try to compile the following code with -Wnullable-to-nonnull-conversion:

#import <Foundation/Foundation.h>

void foo(NSObject * _Nullable x) {
    __auto_type y = x;
    NSObject * _Nonnull z = y;
    // this should warn about nullable-to-nonnull conversion
}

int main(int argc, char *argv[]) {
}

I've attached a zipfile that contains this source and a Makefile so you just run `make`.

Expected Results:
It should warn about a nullable-to-nonnull conversion.

Actual Results:
There is no warning.

Version/Build:
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0

Configuration:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!