]> granicus.if.org Git - clang/commit
When trying to assign a regular string literal to an Objective-C 'id' type or a point...
authorAnders Carlsson <andersca@mac.com>
Tue, 10 Nov 2009 04:46:30 +0000 (04:46 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 10 Nov 2009 04:46:30 +0000 (04:46 +0000)
commitb76cd3d0c166b2162c4709f2ef5da8d67d9844b7
treeb348006c21dceff5e7f6ea9c808ffb48de85a621
parent2f019aadc96f8fa3185c684c7150bd596d045064
When trying to assign a regular string literal to an Objective-C 'id' type or a pointer to an NSString, emit a code insertion hint that turns it into an Objective-C string. For example:

@class NSString;

@interface Test
+ (void)test:(NSString *)string;
@end

void g(NSString *a);

void f() {
  NSString *a = "Foo";
  g("Foo");
  [Test test:"Foo"];
}

will produce

t.m:10:17: warning: incompatible pointer types initializing 'char [4]', expected 'NSString *'
  NSString *a = "Foo";
                ^~~~~
                @
t.m:11:5: warning: incompatible pointer types passing 'char [4]', expected 'NSString *'
  g("Foo");
    ^~~~~
    @
t.m:12:14: warning: incompatible pointer types sending 'char [4]', expected 'NSString *'
  [Test test:"Foo"];
             ^~~~~
             @
3 diagnostics generated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86665 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaExpr.cpp
test/FixIt/fixit-objc.m