1// RUN: %check_clang_tidy %s google-runtime-operator %t
2
3struct Foo {
4 void *operator&();
5// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not overload unary operator&, it is dangerous. [google-runtime-operator]
6};
7
8template <typename T>
9struct TFoo {
10 T *operator&();
11// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not overload unary operator&
12};
13
14TFoo<int> tfoo;
15
16struct Bar;
17void *operator&(Bar &b);
18// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not overload unary operator&
19
20// No warnings on binary operators.
21struct Qux {
22 void *operator&(Qux &q);
23};
24
25void *operator&(Qux &q, Qux &r);
26

source code of clang-tools-extra/test/clang-tidy/checkers/google/overloaded-unary-and.cpp