__auto_type ignores nullability annotations with -fobjc-arc

Originator:kevin
Number:rdar://36877252 Date Originated:January 25 2018, 11:54 AM
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification:Serious Bug Reproducible:Always
 
Summary:
When using __auto_type, Clang ignores nullability annotations if -fobjc-arc is enabled, but it observes them if -fobjc-arc is disabled.

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

#import <Foundation/Foundation.h>

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

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

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

If you compile without -fobjc-arc you get the expected warnings. If you compile with -fobjc-arc there are no warnings.

I've attached a zip that contains this code and a Makefile. Run `make` and it will compile this with and without -fobjc-arc.

Expected Results:
Regardless of the presence or absence of -fobjc-arc, it should produce nullable-to-nonnull warnings.

Actual Results:
When compiled without -fobjc-arc it produces the expected warnings. When compiled with -fobjc-arc there are no warnings.

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!