xref: /llvm-project/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4-friend-in-reachable-class.cpp (revision da00c60dae0040185dc45039c4397f6e746548e9)
1 // This tests for [basic.lookup.argdep]/p4.2:
2 //   Argument-dependent lookup finds all declarations of functions and function templates that
3 // - ...
4 // - are declared as a friend ([class.friend]) of any class with a reachable definition in the set of associated entities,
5 //
6 // RUN: rm -fr %t
7 // RUN: mkdir %t
8 // RUN: split-file %s %t
9 //
10 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/Friend-in-reachable-class.cppm -o %t/X.pcm
11 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/Friend-in-reachable-class.cppm \
12 // RUN:   -o %t/X.reduced.pcm
13 // RUN: %clang_cc1 -std=c++20 -fmodule-file=X=%t/X.pcm %t/Use.cpp -verify -fsyntax-only
14 // RUN: %clang_cc1 -std=c++20 -fmodule-file=X=%t/X.reduced.pcm %t/Use.cpp -verify -fsyntax-only
15 //
16 //--- Friend-in-reachable-class.cppm
17 module;
18 # 3 __FILE__ 1
19 struct A {
operator +(const A & lhs,const A & rhs)20   friend int operator+(const A &lhs, const A &rhs) {
21     return 0;
22   }
23 };
24 # 6 "" 2
25 export module X;
26 export using ::A;
27 
28 //--- Use.cpp
29 // expected-no-diagnostics
30 import X;
use()31 int use() {
32   A a, b;
33   return a + b;
34 }
35