| 1 |
// PR c++/116731 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-Wrange-loop-construct" } |
| 4 |
|
| 5 |
void |
| 6 |
f0 () |
| 7 |
{ |
| 8 |
struct S { |
| 9 |
char a[64]; |
| 10 |
S& operator=(const S&) { return *this; }; |
| 11 |
}; |
| 12 |
|
| 13 |
S arr[8]; |
| 14 |
for (const auto r : arr) |
| 15 |
(void) r; |
| 16 |
} |
| 17 |
|
| 18 |
void |
| 19 |
f1 () |
| 20 |
{ |
| 21 |
struct S { |
| 22 |
char a[65]; |
| 23 |
S& operator=(const S&) { return *this; }; |
| 24 |
}; |
| 25 |
|
| 26 |
S arr[8]; |
| 27 |
for (const auto r : arr) // { dg-warning "creates a copy" } |
| 28 |
(void) r; |
| 29 |
} |
| 30 |
|
| 31 |
void |
| 32 |
f2 () |
| 33 |
{ |
| 34 |
struct S { |
| 35 |
char a[64]; |
| 36 |
S& operator=(const S&) { return *this; }; |
| 37 |
~S() { } |
| 38 |
}; |
| 39 |
|
| 40 |
S arr[8]; |
| 41 |
for (const auto r : arr) // { dg-warning "creates a copy" } |
| 42 |
(void) r; |
| 43 |
} |
| 44 |
|
| 45 |
void |
| 46 |
f3 () |
| 47 |
{ |
| 48 |
struct S { |
| 49 |
char a[65]; |
| 50 |
S& operator=(const S&) { return *this; }; |
| 51 |
~S() { } |
| 52 |
}; |
| 53 |
|
| 54 |
S arr[8]; |
| 55 |
for (const auto r : arr) // { dg-warning "creates a copy" } |
| 56 |
(void) r; |
| 57 |
} |