|
1 |
| -// RUN: %clang_cc1 -fsyntax-only -Wnon-pod-memaccess -verify %s |
| 1 | +// RUN: %clang_cc1 -fsyntax-only -Wdynamic-class-memaccess -verify %s |
2 | 2 |
|
3 | 3 | extern "C" void *memset(void *, int, unsigned);
|
4 | 4 | extern "C" void *memmove(void *s1, const void *s2, unsigned n);
|
5 | 5 | extern "C" void *memcpy(void *s1, const void *s2, unsigned n);
|
6 | 6 |
|
7 |
| -// Several POD types that should not warn. |
| 7 | +// Several types that should not warn. |
8 | 8 | struct S1 {} s1;
|
9 | 9 | struct S2 { int x; } s2;
|
10 | 10 | struct S3 { float x, y; S1 s[4]; void (*f)(S1**); } s3;
|
11 | 11 |
|
12 |
| -// We use the C++11 concept of POD for this warning, so ensure a non-aggregate |
13 |
| -// still warns. |
14 | 12 | class C1 {
|
15 | 13 | int x, y, z;
|
16 | 14 | public:
|
17 | 15 | void foo() {}
|
18 | 16 | } c1;
|
19 | 17 |
|
20 |
| -// Non-POD types that should warn. |
21 |
| -struct X1 { X1(); } x1; |
22 |
| -struct X2 { ~X2(); } x2; |
23 |
| -struct X3 { virtual void f(); } x3; |
24 |
| -struct X4 : X2 {} x4; |
25 |
| -struct X5 : virtual S1 {} x5; |
| 18 | +struct X1 { virtual void f(); } x1; |
| 19 | +struct X2 : virtual S1 {} x2; |
26 | 20 |
|
27 | 21 | void test_warn() {
|
28 | 22 | memset(&x1, 0, sizeof x1); // \
|
29 |
| - // expected-warning {{destination for this 'memset' call is a pointer to non-POD type}} \ |
30 |
| - // expected-note {{explicitly cast the pointer to silence this warning}} |
31 |
| - memset(&x2, 0, sizeof x2); // \ |
32 |
| - // expected-warning {{destination for this 'memset' call is a pointer to non-POD type}} \ |
33 |
| - // expected-note {{explicitly cast the pointer to silence this warning}} |
34 |
| - memset(&x3, 0, sizeof x3); // \ |
35 | 23 | // expected-warning {{destination for this 'memset' call is a pointer to dynamic class}} \
|
36 | 24 | // expected-note {{explicitly cast the pointer to silence this warning}}
|
37 |
| - memset(&x4, 0, sizeof x4); // \ |
38 |
| - // expected-warning {{destination for this 'memset' call is a pointer to non-POD type}} \ |
39 |
| - // expected-note {{explicitly cast the pointer to silence this warning}} |
40 |
| - memset(&x5, 0, sizeof x5); // \ |
| 25 | + memset(&x2, 0, sizeof x2); // \ |
41 | 26 | // expected-warning {{destination for this 'memset' call is a pointer to dynamic class}} \
|
42 | 27 | // expected-note {{explicitly cast the pointer to silence this warning}}
|
43 | 28 |
|
44 | 29 | memmove(&x1, 0, sizeof x1); // \
|
45 |
| - // expected-warning{{destination for this 'memmove' call is a pointer to non-POD type 'struct X1'}} \ |
| 30 | + // expected-warning{{destination for this 'memmove' call is a pointer to dynamic class}} \ |
46 | 31 | // expected-note {{explicitly cast the pointer to silence this warning}}
|
47 | 32 | memmove(0, &x1, sizeof x1); // \
|
48 |
| - // expected-warning{{source of this 'memmove' call is a pointer to non-POD type 'struct X1'}} \ |
| 33 | + // expected-warning{{source of this 'memmove' call is a pointer to dynamic class}} \ |
49 | 34 | // expected-note {{explicitly cast the pointer to silence this warning}}
|
50 | 35 | memcpy(&x1, 0, sizeof x1); // \
|
51 |
| - // expected-warning{{destination for this 'memcpy' call is a pointer to non-POD type 'struct X1'}} \ |
| 36 | + // expected-warning{{destination for this 'memcpy' call is a pointer to dynamic class}} \ |
52 | 37 | // expected-note {{explicitly cast the pointer to silence this warning}}
|
53 | 38 | memcpy(0, &x1, sizeof x1); // \
|
54 |
| - // expected-warning{{source of this 'memcpy' call is a pointer to non-POD type 'struct X1'}} \ |
| 39 | + // expected-warning{{source of this 'memcpy' call is a pointer to dynamic class}} \ |
55 | 40 | // expected-note {{explicitly cast the pointer to silence this warning}}
|
56 | 41 | }
|
57 | 42 |
|
|
0 commit comments