2015-10-22 19:31:44 +08:00
|
|
|
// RUN: %check_clang_tidy %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);
|