Debian Codegraph @

clang/test/CXX/module/module.glob.frag/cxx20-10-4-ex2.cppm

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // RUN: split-file %s %t
4
5 // RUN: %clang_cc1 -std=c++20 %t/std-10-4-ex2-interface.cppm -emit-reduced-module-interface \
6 // RUN: -o %t/M.pcm -Wno-unused-value
7 // RUN: %clang_cc1 -std=c++20 %t/std-10-4-ex2-implementation.cpp -fmodule-file=M=%t/M.pcm \
8 // RUN: -fsyntax-only -verify -Wno-unused-value
9
10 //--- std-10-4-ex2.h
11
12 namespace N {
13 struct X {};
14 int d();
15 int e();
16 inline int f(X, int = d()) { return e(); }
17 int g(X);
18 int h(X);
19 } // namespace N
20
21 //--- std-10-4-ex2-interface.cppm
22 module;
23 #include "std-10-4-ex2.h"
24 export module M;
25
26 template <typename T> int use_f() {
27 N::X x; // N::X, N, and :: are decl-reachable from use_f
28 return f(x, 123); // N::f is decl-reachable from use_f,
29 // N::e is indirectly decl-reachable from use_f
30 // because it is decl-reachable from N::f, and
31 // N::d is decl-reachable from use_f
32 // because it is decl-reachable from N::f
33 // even though it is not used in this call
34 }
35
36 template <typename T> int use_g() {
37 N::X x; // N::X, N, and :: are decl-reachable from use_g
38 return g((T(), x)); // N::g is not decl-reachable from use_g
39 }
40
41 template <typename T> int use_h() {
42 N::X x; // N::X, N, and :: are decl-reachable from use_h
43 return h((T(), x)); // N::h is not decl-reachable from use_h, but
44 // N::h is decl-reachable from use_h<int>
45 }
46
47 int k = use_h<int>();
48 // use_h<int> is decl-reachable from k, so
49 // N::h is decl-reachable from k
50
51 //--- std-10-4-ex2-implementation.cpp
52 module M;
53
54 int a = use_f<int>();
55 int b = use_g<int>();
56 // [email protected]:17 {{use of undeclared identifier 'g'}}
57 // expected-note@-2 {{in instantiation of function template specialization 'use_g<int>' requested here}}
58 int c = use_h<int>();