blob: 2b1223abbe784ea43796248719a096ce013aea45 [file] [log] [blame]
John McCalld1e40d52011-10-02 01:16:38 +00001// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
2// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
John McCallf85e1932011-06-15 23:02:42 +00003
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8void *memset(void *, int, __SIZE_TYPE__);
9void *memmove(void *s1, const void *s2, __SIZE_TYPE__ n);
10void *memcpy(void *s1, const void *s2, __SIZE_TYPE__ n);
11
12#ifdef __cplusplus
13}
14#endif
15
16void test(id __strong *sip, id __weak *wip, id __autoreleasing *aip,
17 id __unsafe_unretained *uip, void *ptr) {
18 // All okay.
19 memset(sip, 0, 17);
20 memset(wip, 0, 17);
21 memset(aip, 0, 17);
22 memset(uip, 0, 17);
23
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000024 memcpy(sip, ptr, 17); // expected-warning{{destination for this 'memcpy' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000025 // expected-note{{explicitly cast the pointer to silence this warning}}
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000026 memcpy(wip, ptr, 17); // expected-warning{{destination for this 'memcpy' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000027 // expected-note{{explicitly cast the pointer to silence this warning}}
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000028 memcpy(aip, ptr, 17); // expected-warning{{destination for this 'memcpy' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000029 // expected-note{{explicitly cast the pointer to silence this warning}}
30 memcpy(uip, ptr, 17);
31
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000032 memcpy(ptr, sip, 17); // expected-warning{{source of this 'memcpy' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000033 // expected-note{{explicitly cast the pointer to silence this warning}}
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000034 memcpy(ptr, wip, 17); // expected-warning{{source of this 'memcpy' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000035 // expected-note{{explicitly cast the pointer to silence this warning}}
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000036 memcpy(ptr, aip, 17); // expected-warning{{source of this 'memcpy' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000037 // expected-note{{explicitly cast the pointer to silence this warning}}
38 memcpy(ptr, uip, 17);
39
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000040 memmove(sip, ptr, 17); // expected-warning{{destination for this 'memmove' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000041 // expected-note{{explicitly cast the pointer to silence this warning}}
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000042 memmove(wip, ptr, 17); // expected-warning{{destination for this 'memmove' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000043 // expected-note{{explicitly cast the pointer to silence this warning}}
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000044 memmove(aip, ptr, 17); // expected-warning{{destination for this 'memmove' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000045 // expected-note{{explicitly cast the pointer to silence this warning}}
46 memmove(uip, ptr, 17);
47
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000048 memmove(ptr, sip, 17); // expected-warning{{source of this 'memmove' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000049 // expected-note{{explicitly cast the pointer to silence this warning}}
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000050 memmove(ptr, wip, 17); // expected-warning{{source of this 'memmove' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000051 // expected-note{{explicitly cast the pointer to silence this warning}}
Argyrios Kyrtzidisb8b03132011-06-24 00:08:59 +000052 memmove(ptr, aip, 17); // expected-warning{{source of this 'memmove' call is a pointer to ownership-qualified type}} \
John McCallf85e1932011-06-15 23:02:42 +000053 // expected-note{{explicitly cast the pointer to silence this warning}}
54 memmove(ptr, uip, 17);
55}
Douglas Gregor4eb75222011-07-30 06:45:27 +000056
57void rdar9772982(int i, ...) {
58 __builtin_va_list ap;
59
60 __builtin_va_start(ap, i);
61 __builtin_va_arg(ap, __strong id); // expected-error{{second argument to 'va_arg' is of ARC ownership-qualified type '__strong id'}}
62 __builtin_va_end(ap);
63}