2015-08-21 01:58:07 +08:00
|
|
|
// RUN: %python %S/check_clang_tidy.py %s google-runtime-operator %t
|
2014-07-15 20:48:14 +08:00
|
|
|
|
|
|
|
struct Foo {
|
|
|
|
void *operator&();
|
2014-10-26 10:58:07 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not overload unary operator&, it is dangerous. [google-runtime-operator]
|
2014-07-15 20:48:14 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct TFoo {
|
|
|
|
T *operator&();
|
2014-10-26 10:58:07 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not overload unary operator&
|
2014-07-15 20:48:14 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
TFoo<int> tfoo;
|
|
|
|
|
|
|
|
struct Bar;
|
|
|
|
void *operator&(Bar &b);
|
2014-10-26 10:58:07 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not overload unary operator&
|
2014-07-15 20:48:14 +08:00
|
|
|
|
2014-10-26 10:58:07 +08:00
|
|
|
// No warnings on binary operators.
|
2014-07-15 20:48:14 +08:00
|
|
|
struct Qux {
|
2014-10-26 10:58:07 +08:00
|
|
|
void *operator&(Qux &q);
|
2014-07-15 20:48:14 +08:00
|
|
|
};
|
|
|
|
|
2014-10-26 10:58:07 +08:00
|
|
|
void *operator&(Qux &q, Qux &r);
|