xref: /aosp_15_r20/external/clang/test/FixIt/format-no-fixit.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -fsyntax-only %s 2>&1 | FileCheck %s
3*67e74705SXin Li
4*67e74705SXin Li// CHECK-NOT: fix-it:
5*67e74705SXin Li
6*67e74705SXin Li@class NSString;
7*67e74705SXin Liextern void NSLog(NSString *format, ...);
8*67e74705SXin Liint printf(const char * restrict, ...) ;
9*67e74705SXin Li
10*67e74705SXin Li
11*67e74705SXin Livoid test_object_correction (id x) {
12*67e74705SXin Li  printf("%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'id'}}
13*67e74705SXin Li  printf("%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'id'}}
14*67e74705SXin Li  printf("%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'id'}}
15*67e74705SXin Li}
16*67e74705SXin Li
17*67e74705SXin Li
18*67e74705SXin Li// Old-style Core Foundation types do not have __attribute__((NSObject)).
19*67e74705SXin Li// This is okay, but we won't suggest a fixit; arbitrary structure pointers may
20*67e74705SXin Li// not be objects.
21*67e74705SXin Litypedef const struct __CFString * CFStringRef;
22*67e74705SXin Li
23*67e74705SXin Livoid test_cf_object_correction (CFStringRef x) {
24*67e74705SXin Li  NSLog(@"%@", x); // no-warning
25*67e74705SXin Li
26*67e74705SXin Li  NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'CFStringRef'}}
27*67e74705SXin Li  NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'CFStringRef'}}
28*67e74705SXin Li  NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'CFStringRef'}}
29*67e74705SXin Li}
30*67e74705SXin Li
31