John McCall | d1e40d5 | 2011-10-02 01:16:38 +0000 | [diff] [blame] | 1 | // 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 McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | void *memset(void *, int, __SIZE_TYPE__); |
| 9 | void *memmove(void *s1, const void *s2, __SIZE_TYPE__ n); |
| 10 | void *memcpy(void *s1, const void *s2, __SIZE_TYPE__ n); |
| 11 | |
| 12 | #ifdef __cplusplus |
| 13 | } |
| 14 | #endif |
| 15 | |
| 16 | void 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 Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 24 | memcpy(sip, ptr, 17); // expected-warning{{destination for this 'memcpy' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 25 | // expected-note{{explicitly cast the pointer to silence this warning}} |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 26 | memcpy(wip, ptr, 17); // expected-warning{{destination for this 'memcpy' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 27 | // expected-note{{explicitly cast the pointer to silence this warning}} |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 28 | memcpy(aip, ptr, 17); // expected-warning{{destination for this 'memcpy' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 29 | // expected-note{{explicitly cast the pointer to silence this warning}} |
| 30 | memcpy(uip, ptr, 17); |
| 31 | |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 32 | memcpy(ptr, sip, 17); // expected-warning{{source of this 'memcpy' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 33 | // expected-note{{explicitly cast the pointer to silence this warning}} |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 34 | memcpy(ptr, wip, 17); // expected-warning{{source of this 'memcpy' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 35 | // expected-note{{explicitly cast the pointer to silence this warning}} |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 36 | memcpy(ptr, aip, 17); // expected-warning{{source of this 'memcpy' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 37 | // expected-note{{explicitly cast the pointer to silence this warning}} |
| 38 | memcpy(ptr, uip, 17); |
| 39 | |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 40 | memmove(sip, ptr, 17); // expected-warning{{destination for this 'memmove' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 41 | // expected-note{{explicitly cast the pointer to silence this warning}} |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 42 | memmove(wip, ptr, 17); // expected-warning{{destination for this 'memmove' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 43 | // expected-note{{explicitly cast the pointer to silence this warning}} |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 44 | memmove(aip, ptr, 17); // expected-warning{{destination for this 'memmove' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 45 | // expected-note{{explicitly cast the pointer to silence this warning}} |
| 46 | memmove(uip, ptr, 17); |
| 47 | |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 48 | memmove(ptr, sip, 17); // expected-warning{{source of this 'memmove' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 49 | // expected-note{{explicitly cast the pointer to silence this warning}} |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 50 | memmove(ptr, wip, 17); // expected-warning{{source of this 'memmove' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 51 | // expected-note{{explicitly cast the pointer to silence this warning}} |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 52 | memmove(ptr, aip, 17); // expected-warning{{source of this 'memmove' call is a pointer to ownership-qualified type}} \ |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 53 | // expected-note{{explicitly cast the pointer to silence this warning}} |
| 54 | memmove(ptr, uip, 17); |
| 55 | } |
Douglas Gregor | 4eb7522 | 2011-07-30 06:45:27 +0000 | [diff] [blame] | 56 | |
| 57 | void 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 | } |