annotate clang/test/SemaObjC/warn-nontrivial-struct-memaccess.m @ 180:680fa57a2f20

fix compile errors.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 30 May 2020 17:44:06 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime-has-weak -x objective-c -fobjc-arc -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 void *memset(void *, int, __SIZE_TYPE__);
anatofuz
parents:
diff changeset
4 void bzero(void *, __SIZE_TYPE__);
anatofuz
parents:
diff changeset
5 void *memcpy(void *, const void *, __SIZE_TYPE__);
anatofuz
parents:
diff changeset
6 void *memmove(void *, const void *, __SIZE_TYPE__);
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 struct Trivial {
anatofuz
parents:
diff changeset
9 int f0;
anatofuz
parents:
diff changeset
10 volatile int f1;
anatofuz
parents:
diff changeset
11 };
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 struct NonTrivial0 {
anatofuz
parents:
diff changeset
14 int f0;
anatofuz
parents:
diff changeset
15 __weak id f1; // expected-note 2 {{non-trivial to default-initialize}} expected-note 2 {{non-trivial to copy}}
anatofuz
parents:
diff changeset
16 volatile int f2;
anatofuz
parents:
diff changeset
17 id f3[10]; // expected-note 2 {{non-trivial to default-initialize}} expected-note 2 {{non-trivial to copy}}
anatofuz
parents:
diff changeset
18 };
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 struct NonTrivial1 {
anatofuz
parents:
diff changeset
21 id f0; // expected-note 2 {{non-trivial to default-initialize}} expected-note 2 {{non-trivial to copy}}
anatofuz
parents:
diff changeset
22 int f1;
anatofuz
parents:
diff changeset
23 struct NonTrivial0 f2;
anatofuz
parents:
diff changeset
24 };
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 void testTrivial(struct Trivial *d, struct Trivial *s) {
anatofuz
parents:
diff changeset
27 memset(d, 0, sizeof(struct Trivial));
anatofuz
parents:
diff changeset
28 bzero(d, sizeof(struct Trivial));
anatofuz
parents:
diff changeset
29 memcpy(d, s, sizeof(struct Trivial));
anatofuz
parents:
diff changeset
30 memmove(d, s, sizeof(struct Trivial));
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 void testNonTrivial1(struct NonTrivial1 *d, struct NonTrivial1 *s) {
anatofuz
parents:
diff changeset
34 memset(d, 0, sizeof(struct NonTrivial1)); // expected-warning {{that is not trivial to primitive-default-initialize}} expected-note {{explicitly cast the pointer to silence}}
anatofuz
parents:
diff changeset
35 memset((void *)d, 0, sizeof(struct NonTrivial1));
anatofuz
parents:
diff changeset
36 bzero(d, sizeof(struct NonTrivial1)); // expected-warning {{that is not trivial to primitive-default-initialize}} expected-note {{explicitly cast the pointer to silence}}
anatofuz
parents:
diff changeset
37 memcpy(d, s, sizeof(struct NonTrivial1)); // expected-warning {{that is not trivial to primitive-copy}} expected-note {{explicitly cast the pointer to silence}}
anatofuz
parents:
diff changeset
38 memmove(d, s, sizeof(struct NonTrivial1)); // expected-warning {{that is not trivial to primitive-copy}} expected-note {{explicitly cast the pointer to silence}}
anatofuz
parents:
diff changeset
39 }