annotate clang/test/SemaObjC/format-arg-attribute.m @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -verify -fsyntax-only %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 @class NSString;
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
4 @class NSAttributedString;
150
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 extern NSString *fa2 (const NSString *) __attribute__((format_arg(1)));
anatofuz
parents:
diff changeset
7 extern NSString *fa3 (NSString *) __attribute__((format_arg(1)));
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 extern void fc1 (const NSString *) __attribute__((format_arg)); // expected-error {{'format_arg' attribute takes one argument}}
anatofuz
parents:
diff changeset
10 extern void fc2 (const NSString *) __attribute__((format_arg())); // expected-error {{'format_arg' attribute takes one argument}}
anatofuz
parents:
diff changeset
11 extern void fc3 (const NSString *) __attribute__((format_arg(1, 2))); // expected-error {{'format_arg' attribute takes one argument}}
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to Objective-C methods and non-K&R-style functions}}
anatofuz
parents:
diff changeset
14 union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to}}
anatofuz
parents:
diff changeset
15 enum e1 { E1V0 } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to}}
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 extern NSString *ff3 (const NSString *) __attribute__((format_arg(3-2)));
anatofuz
parents:
diff changeset
18 extern NSString *ff4 (const NSString *) __attribute__((format_arg(foo))); // expected-error {{use of undeclared identifier 'foo'}}
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 /* format_arg formats must take and return a string. */
anatofuz
parents:
diff changeset
21 extern NSString *fi0 (int) __attribute__((format_arg(1))); // expected-error {{format argument not a string type}}
anatofuz
parents:
diff changeset
22 extern NSString *fi1 (NSString *) __attribute__((format_arg(1)));
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 extern NSString *fi2 (NSString *) __attribute__((format_arg(1)));
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 extern int fi3 (const NSString *) __attribute__((format_arg(1))); // expected-error {{function does not return NSString}}
anatofuz
parents:
diff changeset
27 extern NSString *fi4 (const NSString *) __attribute__((format_arg(1)));
anatofuz
parents:
diff changeset
28 extern NSString *fi5 (const NSString *) __attribute__((format_arg(1)));
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
29
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
30 extern NSAttributedString *fattrs (const NSString *) __attribute__((format_arg(1)));