| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
// { dg-additional-options "-Wparentheses -Wno-non-template-friend" } |
| 3 |
|
| 4 |
// the MVP warning triggered on a friend decl. */ |
| 5 |
class X; |
| 6 |
enum class Q {}; // C++ 11ness |
| 7 |
enum R {}; |
| 8 |
|
| 9 |
namespace here |
| 10 |
{ |
| 11 |
// these friends |
| 12 |
X friendFunc1(); |
| 13 |
X *friendFunc2 (); |
| 14 |
int friendFunc3 (); |
| 15 |
int bob (); |
| 16 |
Q bill (); |
| 17 |
R ben (); |
| 18 |
} |
| 19 |
|
| 20 |
namespace nm |
| 21 |
{ |
| 22 |
namespace here |
| 23 |
{ |
| 24 |
// Not these friends |
| 25 |
void friendFunc1 (); |
| 26 |
void friendFunc2 (); |
| 27 |
void friendFunc3 (); |
| 28 |
int bob (); |
| 29 |
Q bill (); |
| 30 |
R ben (); |
| 31 |
} |
| 32 |
|
| 33 |
class TestClass |
| 34 |
{ |
| 35 |
friend X (::here::friendFunc1 ()); // parens are needed |
| 36 |
friend X *(::here::friendFunc2 ()); // { dg-warning "" } |
| 37 |
friend X *::here::friendFunc2 (); |
| 38 |
friend int (::here::friendFunc3 ()); // { dg-warning "" } |
| 39 |
}; |
| 40 |
|
| 41 |
template <typename T> class X |
| 42 |
{ |
| 43 |
friend typename T::frob (::here::bob ()); |
| 44 |
friend Q (::here::bill ()); |
| 45 |
friend R (::here::ben ()); |
| 46 |
}; |
| 47 |
} |
| 48 |
|