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